Public
Edited
Mar 16, 2023
13 forks
80 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards
.rename({ spp: "code" })
.join_left(codebook)
.filter((d) => d.tail == "W" && d.sex == "M")
.groupby("common_name")
.rollup({ avg_length: (d) => op.mean(d.total_length) })
.derive({ length_cm: (d) => d.avg_length / 10 })
.orderby(aq.desc("length_cm"))
.select("common_name", "length_cm")
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { aq, op } from "@uwdata/arquero"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards = aq.from(lizardsPitfallData)
Insert cell
codebook = aq.from(lizardCodebook)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards.filter((d) => d.spp === "PHCO").view(5) // .view(5) here returns the first 5 rows of outcome
Insert cell
lizards.filter((d) => d.spp === "COTE" && d.weight <= 20).view(5)
Insert cell
Insert cell
Insert cell
Insert cell
lizards.select("spp", "site", "total_length").view(5)
Insert cell
lizards.select(aq.not("zone", "plot", "pit")).view(5)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards
.groupby("spp", "sex")
.rollup({mean_wt: d => op.mean(d.weight)})
.view(5)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards
.derive({spp_lower: d => op.lower(d.spp)})
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
codebook
.rename({scientific_name: "sci"},
{common_name: "common"})
.view(5)
Insert cell
Insert cell
Insert cell
Insert cell
lizards
.relocate(["spp","total_length", "weight"], { after: 'date' })
.view(5)
Insert cell
Insert cell
Insert cell
Insert cell
codebook
.spread(
{ name_split: (d) => op.split(d.scientific_name, " ") },
{ as: ["genus", "species"] }
)
.view(5)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
lizards
.fold(['total_length', 'weight'], { as: ['record', 'record_values'] })
.view(5)
Insert cell
Insert cell
weight_tbl = lizards
.filter(d => d.spp === "CNTE" || d.spp === "CNIN")
.groupby("spp", "sex")
.rollup({mean_wt: d => op.mean(d.weight)})
Insert cell
Insert cell
Insert cell
Insert cell
weight_tbl
.groupby("spp")
.pivot("sex", "mean_wt")
.view()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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