Published
Edited
Feb 14, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
myFile = FileAttachment("student_debt.csv").csv()
Insert cell
Insert cell
d3.csvParse(await FileAttachment("student_debt.csv").text(), d3.autoType)
Insert cell
Insert cell
data = {
const text = await FileAttachment("student_debt.csv").text();
const parseDate = d3.utcParse("%Y");
return d3.csvParse(text, ({year, race, type, value}) => ({
year: parseDate(year),
race: race,
type: type,
value: +value
}));
}
Insert cell
Insert cell
Insert cell
data_groups = d3.groups(data, d => d.race, d => d.type)
Insert cell
md`data_groups above uses d3.groups creates a nested array. Below I use d3.group and it creates a data map. `
Insert cell
data_group = d3.group(data, d => d.race, d => d.type)
Insert cell
Insert cell
data_filter = data.filter(d => d.type =="loan_debt")
Insert cell
Insert cell
d3.rollup(data_filter, v => d3.sum(v, d => d.value))
Insert cell
Insert cell
d3.rollup(data_filter, v => d3.sum(v, d => d.value), d => d.race)
Insert cell
Insert cell
Insert cell
Insert cell
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