Public
Edited
May 19
Insert cell
Insert cell
Insert cell
population = FileAttachment("almost_done.json").json()
.then((data) =>
data
.slice(1)
.map(([p, state, county, category, personName, source]) => ({
state,
fips: `${state}${county}`,
population: +p,
category,
personName,
source
}))
)
Insert cell
centroid = {
const path = d3.geoPath();
return feature => path.centroid(feature);
}
Insert cell
us = FileAttachment("counties-albers-10m.json").json()
Insert cell
nation = topojson.feature(us, us.objects.nation)
Insert cell
statemap = new Map(topojson.feature(us, us.objects.states).features.map(d => [d.id, d]))
Insert cell
Insert cell
statemesh = topojson.mesh(us, us.objects.states, (a, b) => a !== b)
Insert cell
spike = (length, width = 7) => `M${-width / 2},0L0,${-length}L${width / 2},0`
Insert cell
povertyData = FileAttachment("cleaned_poverty_data.csv").csv({typed: true})
Insert cell
unemployment = FileAttachment("unemployment201907.csv").csv({typed: true})
Insert cell
namemap = new Map(us.objects.states.geometries.map(d => [d.properties.name, d.id]))
Insert cell
valuemap = new Map(unemployment.map(d => [d.name, d.rate]))
Insert cell
workbook = FileAttachment("all_billionaires_1997_2024.csv").csv()
Insert cell
Insert cell
Insert cell
workbook.filter((element) => {
return element.country_of_residence == "United States"
})
Insert cell
data = workbook.filter((element) => {
return element.country_of_residence == "United States"
})
Insert cell
function titleCase(str) {
return str.toLowerCase().replace(/\b\w/g, s => s.toUpperCase());
}
Insert cell
fipsTranslatorRaw = FileAttachment("State__County_and_City_FIPS_Reference_Table_20250519.csv").csv()
Insert cell
fipsTranslator = fipsTranslatorRaw.reduce((acc, x) => ({...acc, [titleCase(x['City Name'])]: x['StCnty FIPS Code']}), {})
Insert cell
cleanedData = data.map(currentElement => ({
year: currentElement.year,
rank: currentElement.rank,
net_worth: currentElement.net_worth,
full_name: currentElement.full_name,
fips: fipsTranslator[currentElement.city_of_residence],
business_industries: currentElement.business_industries,
organization_name: currentElement.organization_name
}))
Insert cell
cleanedData = data.map(currentElement => ({
year: currentElement.year,
rank: currentElement.rank,
net_worth: currentElement.net_worth,
full_name: currentElement.full_name,
fips: fipsTranslator[currentElement.city_of_residence],
business_industries: currentElement.business_industries,
organization_name: currentElement.organization_name
}))
Insert cell
cleanedDatafipundef = cleanedData.filter((element) => {
return (typeof element.fips == 'undefined')
})
Insert cell
cdfu = cleanedDatafipundef.map(currentElement => ({
full_name: currentElement.full_name
})).reduce((acc, x) => ({...acc, [x.full_name]: true}), {})
Insert cell
fipsnf = data.filter((element) => {
return (typeof cdfu[element.full_name] !== 'undefined')
}).map(currentElement => ({
city_of_residence: currentElement.city_of_residence
}))
Insert cell
[...new Set(fipsnf.map(d => d.city_of_residence))]
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