Published
Edited
Dec 14, 2021
1 fork
Importers
43 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Join temperature data onto our data to analyze its effect
data = aq
.from(demand)
.join(aq.from(temperature_with_features))
.rename({ air_temp: "temp", value: "demand" })
.select(aq.not("id", "name"))
.objects()

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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Storing the labels separately
labels = ({
hour: new Map(_.range(24).map((d) => [d, d + ":00"])),
day: new Map(weekdays.map((d, i) => [i, d])),
month: new Map(months.map((d, i) => [i, d])),
quarter: new Map([
[0, "Q1: Jan - Mar"],
[1, "Q2: Apr - Jun"],
[2, "Q3: Jul - Sep"],
[3, "Q4: Oct - Dec "]
]),
weekend: new Map([
[0, "Weekday"],
[1, "Weekend"]
]),
week: new Map(_.range(54).map((d) => [d, d])),
daytime: new Map([
[0, "Work hours"],
[1, "Evening"],
[2, "Night"]
]),
feel: new Map([
[0, "cold"],
[1, "moderate"],
[2, "hot"]
])
})
Insert cell
// Load the Temporal API using a Polyfill
Temporal = {
const TemporalLib = await require("@js-temporal/polyfill@0.2.0");
return TemporalLib.Temporal;
}
Insert cell
Insert cell
Insert cell
import {months, weekdays} from "@observablehq/discovering-date-patterns"
Insert cell
import {Legend, Swatches} from "@d3/color-legend"
Insert cell
import {authorship, altauthorship, navigation, workshop} from "@observablehq/timeseries-assets"
Insert cell
import {addTooltips} from "@mkfreeman/plot-tooltip"
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