Public
Edited
Jan 3, 2024
Insert cell
Insert cell
raw = FileAttachment("owid-co2-data.csv").csv()
Insert cell
Insert cell
reduced_data = Object.values(raw.reduce((acumulator, current) => {
let key = `${current.country}-${current.year}`
const country = countries_loc.find(element => element.Country == current.country)

if(country != undefined){
sectors.map(sector => {
const new_key = key + `-${sector}`
acumulator[new_key] = {
country: current.country,
year: current.year,
sector: sector,
co2: current[`${sector == "luc"? "land_use_change" : sector == "other"? "other_industry" : sector}_co2`],
cumulative_co2: current[`cumulative_${sector}_co2`],
share_global_co2: current[`share_global_${sector}_co2`],
share_global_cumulative_co2: current[`share_global_cumulative_${sector}_co2`],
longitude: country.Longitude,
latitude: country.Latitude
}
})
}

return acumulator
}, {}))
Insert cell
reduced_data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
countries_loc = FileAttachment("countries_lon_lat.csv").csv()
Insert cell
countries_list = country_continent.map(obj => obj.country);
Insert cell
emissionsCountry = emissions[country].data
Insert cell
emissions = (
await fetch(
"https://nyc3.digitaloceanspaces.com/owid-public/data/co2/owid-co2-data.json"
)
).json()
Insert cell
import { toc } from "@nebrius/indented-toc"
Insert cell
import {joinArrays} from "56f7c9059e8ab6d1"
Insert cell
import {Scrubber} from "@mbostock/scrubber"
Insert cell
import {boxStyles} from "@udg-master-data-science/data-playground"
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