Public
Edited
Mar 14, 2023
1 fork
Insert cell
Insert cell
Insert cell
powerplants_allUS_2021.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
data = FileAttachment("powerplants_allUS_2021.csv").csv() // parse the CSV file into an Array (list)
Insert cell
toNum = (text) => Number(text.replace(/,/g,'')); // a function to strip commas and make a number
Insert cell
data.forEach(d => {
// then iterate through the full dataset and clean two columns that we need.
if (d["Plant annual net generation (MWh)"] != null) {d["Plant annual net generation (MWh)"] = toNum(d["Plant annual net generation (MWh)"])}
if (d["Plant annual CO2 equivalent emissions (tons)"] != null) {d["Plant annual CO2 equivalent emissions (tons)"] = toNum(d["Plant annual CO2 equivalent emissions (tons)"])}
})
Insert cell
Insert cell
Insert cell
<svg width="1000" height="1000">
<text x="20" y="35" style="font-size:24px; font-family: sans-serif">U.S. Power Plants</text>
</svg>
Insert cell
viz = d3.select(powerplants) // select the SVG cell as a D3 object called viz
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more