Public
Edited
Mar 2, 2023
Insert cell
Insert cell
x = 3
Insert cell
y = 4
Insert cell
Insert cell
X is equal to ${x}
Insert cell
moment = require("moment")
Insert cell
jan1st = moment("2023-01-02")
Insert cell
first = "aadit"
Insert cell
last = "tambe"
Insert cell
${first} ${last}
Insert cell
function add(a,b){
return a+ b
}
Insert cell
add(2,3)
Insert cell
import {san_diego_stops} from '@eads/first-observable-notebook-imports'
Insert cell
data =aq.from(san_diego_stops)
Insert cell
sample5 = data.sample(5)
Insert cell
viewof showAnother = Inputs.button('show me another')
Insert cell
sample_stop = {
showAnother
return data.sample(1).object(0)
}
Insert cell
Insert cell
// import {cases_judges} from "@eads/first-observable-notebook-data-work"
Insert cell
variables = ["B01003_001E"]
Insert cell
url = `https://api.census.gov/data/2021/acs/acs5?get=NAME,${Array.from(variables.values())}&for=place:04416&in=state:39`
Insert cell
function graphql(payload, headers = {}) {
headers["content-type"] = "application/json";
return fetch("https://ohiocourts.hasura.app/v1/graphql", {
body: JSON.stringify(payload),
headers: headers,
method: "POST",
mode: "cors"
})
.then((response) => {
return response.json();
})
.then((jsonData) => {
return jsonData.data;
});
}
Insert cell
cases_judges = graphql({
operationName: "MyQuery",
query: `
query MyQuery {
cases {
case_year
judge
arresting_agency
}
}
`
})
Insert cell
cases_judges_dt = aq.from(cases_judges.cases)
Insert cell
import { aq, op } from "@uwdata/arquero"
Insert cell
cases_judges_dt
.groupby("arresting_agency")
.count()
.orderby(aq.desc("count"))
.view()
Insert cell
cases_judges_dt
.groupby("arresting_agency", "case_year")
// Here is the full form of count!
.rollup({county:op.count()})
.orderby(aq.desc("county"))
.view()
Insert cell
cases_judges_dt
.groupby("arresting_agency", "case_year")
.count()
.filter(d=>d.case_year==2021)
.join(
cases_judges_dt
.groupby("arresting_agency", "case_year")
.count()
.filter(d=>d.case_year==2016),
"arresting_agency")
.derive({pct_increase: d=>(d.count_1-d.count_2)*100/d.count_2})
.orderby(aq.desc("pct_increase"))
//.filter(d=>d.count_1+d.count_2>100)
.view()
Insert cell
penguins
Insert cell
Plot.plot({
color: {
legend: true
},
caption: "penguin length",
style:{
background: "pink",
},
marks: [
Plot.dot(penguins, {
x:"flipper_length_mm",
y: "body_mass_g",
fill: "sex",
})
]
})
Insert cell
Plot.plot({
color: {
legend: true
},
caption: "penguin length",
style:{
// background: "pink",
},
marks: [
Plot.dot(penguins, {
x:"flipper_length_mm",
y: "body_mass_g",
fill: "sex",
opacity: 4
})
]
})
Insert cell
Plot.auto(penguins, {x:"culmen_depth_mm", y: "culmen_length_mm"}).plot()

Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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