Public
Edited
May 28, 2023
Insert cell
Insert cell
Insert cell
FileAttachment("temperature.csv")
Insert cell
Insert cell
FileAttachment("temperature.csv").text()
Insert cell
Insert cell
FileAttachment("temperature.csv").csv()
Insert cell
Insert cell
Insert cell
"62.7" + "59.9" // 122.6? Nope!
Insert cell
Insert cell
FileAttachment("temperature.csv").csv({typed: true})
Insert cell
manipulated = FileAttachment("temperature.csv").csv({typed: true})
Insert cell
manipulated[0].temperature * (5 / 4) - 32

Insert cell
temp = 24
Insert cell
conv_to_c = (temp - 32) * (5 / 9)
Insert cell
conv_to_f = (temp * (9/5)) + 32
Insert cell
Insert cell
Insert cell
1 + 1
Insert cell
name = "melissa"
Insert cell
[...name].reverse().join("")
Insert cell
Insert cell
sum = {
let s = 0;
for (let i = 0; i < 10; ++i) {
s += i;
}
return s;
}
Insert cell
// generate an array of random length with random numbers between 0 and the length of the array
randsumarray = {
let a = []
let s = Math.random() * 1000
for (let i = 0; i < s; ++i) {
let val = Math.floor(Math.random() * s)
a.push(val)
}
return a
}
Insert cell
Histogram(randsumarray)
Insert cell
// I would expect the ration of mean to length to stay approximately constant
summarystats = {
let stats = {
min: d3.min(randsumarray),
median: d3.median(randsumarray),
mean: d3.mean(randsumarray),
max: d3.max(randsumarray),
ratio_mean_to_length: d3.mean(randsumarray) / randsumarray.length
}
return stats
}
Insert cell
Insert cell
sum
Insert cell
s // not defined!
Insert cell
Insert cell
data = {
const text = await FileAttachment("temperature.csv").text();
const parseDate = d3.utcParse("%Y-%m-%d");
return d3.csvParse(text, ({date, temperature}) => ({
date: parseDate(date),
temperature: +temperature
}));
}
Insert cell
Insert cell
d3.extent(data, d => d.date)
Insert cell
d3.extent(data, d => d.temperature)
Insert cell
Insert cell
import {Histogram} from "@d3/histogram"
Insert cell
Histogram(data, {value: d => d.temperature, width, height})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
height = 200
Insert cell
import {keyStyled} from "@mbostock/keys"
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