Public
Edited
Dec 12, 2022
Insert cell
Insert cell
Insert cell
pres_data = FileAttachment("1976-2020-president@1.csv").csv()
Insert cell
temp = new Set();
Insert cell
data = FileAttachment("US-household-income.csv").csv();
Insert cell
states = data.columns.slice(2);
Insert cell
dataFormatted = {
return data.map(obj => ({
year: Number(obj.DATE.split("/")[2]),
us: Number(obj.US),
states: {...obj}
}))
};
Insert cell
US-household-income.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
viewof range = Inputs.range([84, 21], {label: "Year", step: 1})
Insert cell
viewof range2 = Inputs.range([84,21], {label: "Year", step: 1})
Insert cell
viewof state = Inputs.select(states);
Insert cell
viewof state2 = Inputs.select(states);
Insert cell
Insert cell
db
incomes2 = DuckDBClient.of({
incomes: {
file: FileAttachment("US-household-income.csv"),
dateFormat: "%b %d %Y"
}
})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(dataFormatted, {x: "year", y: "US"})
]
})
Insert cell
Plot.plot({
marks: [
Plot.barY(data, {x: "DATE", y: state,}),
Plot.ruleY([0])
],
})
Insert cell
db = DuckDBClient.of({
incomes: FileAttachment("sql-income.csv"),
political: FileAttachment("sen-plain.csv"),
unemployment: FileAttachment("emp-unemployment@2.csv")
})
Insert cell
db
SELECT * FROM political
Insert cell
db
select political.year, political.US_sens, incomes.US, incomes.Alabama, political.Alabama_sens from political
inner join incomes on political.year=incomes.year
where incomes.year =2001
Insert cell
db
select * from incomes
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