Public
Edited
Apr 14, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
descriptions = {
if (activity == null) {
return [null];
} else {
return [null].concat(grouped.get(activity).map(d => d["('Description', '')"]))
}
}
Insert cell
import {weight_input, weight_kg} from "59248563da107bc7"
Insert cell
compendiumofphysicalactivities = FileAttachment("compendiumofphysicalactivities.json").json()
Insert cell
Inputs.table(compendiumofphysicalactivities)
Insert cell
Object.keys(compendiumofphysicalactivities[0])
Insert cell
grouped = d3.group(compendiumofphysicalactivities, d => d["('Category', '')"])
Insert cell
categories = Array.from(grouped, ([k, v]) => k)
Insert cell
grouped.get("bicycling")
Insert cell
description
Insert cell
grouped.get(activity).filter(d => d["('Description', '')"] == description)[0]["('2011 Compendium', 'METs')"]
Insert cell
MET = {
if (activity == null) {
return "0.0";
}
if (grouped.get(activity).filter(d => d["('Description', '')"] == description).length == 0) {
return "0.0";
} else if (grouped.get(activity).filter(d => d["('Description', '')"] == description).length > 1) {
return "-1.0";
} else {
return grouped.get(activity).filter(d => d["('Description', '')"] == description)[0]["('2011 Compendium', 'METs')"]
}
}
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