Published
Edited
Oct 23, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aita = await FileAttachment("aita_clean_appended.csv").text()
Insert cell
aita_parsed = await d3.csvParse(aita)
Insert cell
table(aita_parsed)
Insert cell
aita_parsed.columns
Insert cell
viewof aitaBar = vl.markBar() // Make a bar chart
.data(aita_parsed) // Using the data
.encode(
vl.x().fieldN("verdict"),
vl.y().field("Frequency").axis({ format: "%" })
)
.render()
Insert cell
Insert cell
Insert cell
md ` # Candidate data:
1. RDIndex2019
2. Candidate UUID
3. State
4. Office Level
5. Office Role
6. OCDID
7. Electoral District
8. Office UUID
8. Office Name (ex. "solicitor general," "county prosecuting attorney")
9. Seat Type (empty?)
10. Seat ID (empty?)
11. Number elected (so far only seems to be 1)
12. Candidate Name
13. Candidate Party ("Republican Party","Democratic Party" )
14. Party ID Roll up
15. White/Non-White ("White" vs "Non-White strings)
16. Race ("White","Unknown","American Indian or Alaska Native","Hispanic or Latino","Asian American or Pacific Islander","Multiracial","Black or African American")
17. Gender ("Male", "Female" and)
18. Winner Y/N ("True" or "False")
`
Insert cell
elected_officials19 = FileAttachment("elected_officials_rd2019.csv").csv()
Insert cell
table(candidates19)
Insert cell
md ` # Elected Officials data:
1. RDIndex2019
2. State
3. Office Level
4. Office Role
5. OCDID
5. Electoral District
6. Office Name
7. Official Name (of elected official)
8. Official Party ("Nonpartisan",
9. Party Roll Up ("Independent",
10. White/Non-White ("White","Non-White","Unknown")
11. Race ("White","Unknown","American Indian or Alaska Native","Hispanic or Latino","Asian American or Pacific Islander","Multiracial","Black or African American")
12. Gender ("Male", "Female", and "Unknown")
`
Insert cell
table(elected_officials19)
Insert cell
elected_officials19.columns
Insert cell
candidates19.columns
Insert cell
viewof canBar = vl.markBar() // Make a bar chart
.data(candidates19) // Using the data
.encode(
vl.x().fieldN("Office Role"), // .sort(vl.fieldQ("frequency").order("descending")), // Letters are ordinal on the x-axis
vl.y().fieldN("Gender").axis({ format: "%" }) // Frequency on the y-axis, formatted as percent
)
.render()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require ('d3')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more