Published
Edited
Feb 6, 2022
Insert cell
Insert cell
Insert cell
data = FileAttachment("Cameras@4.csv").csv({typed: true})
//Imports data, and automatically types the objects (eg int/str)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md` #### Max/Min
Max Price: $${
d3.max(data, d => d.Price)}\n
Min Price: $${
d3.min(data, d => d.Price)}
`
Insert cell
md`#### Sum: \n Total weight:
${
d3.sum(data, d => d.Weight)} grams`
Insert cell
md`#### Average\n Mean Weight: ${
d3.mean(data.filter(d => d.Weight > 0),
d => d.Weight).toFixed(2)} grams

Median Weight: ${
d3.median(data.filter(d => d.Weight > 0),
d => d.Weight).toFixed(2)} (both excluding 0s)\n
(Most cameras weigh around 200g, but there are a few heavier cameras.)`

Insert cell
md`#### Counting records of a particular dimension\n
Most common Low Resolution: ${
d3.mode(data.filter(d => d.Lowresolution > 0),
d => d.Lowresolution)}p\n
No. of cameras with Low Resolution of 2048: ${
d3.count(data.filter(d => d.Lowresolution >= 2047 && d.Lowresolution <= 2049),
d => d.Maxresolution)}`
//idk why I can't do == 2048 but this works lol`

Insert cell
Insert cell
Insert cell
VegaLite({
data: {values: data},
mark: "bar",
encoding: {
x:{field: "Releasedate", type: "nominal"},
y:{aggregate: "count", type: "quantitative"},}
})
Insert cell
Insert cell
vl.markBar()
.data(data.filter(d => d.Normalfocusrange > 0))
.encode(
vl.x().fieldQ("Normalfocusrange").bin({bin: true, step: 10}),
vl.y().count(),
) .render()
Insert cell
Insert cell
vl.markBar()
.data(data.filter(d => d.Storageincluded < 100))
.encode(
vl.x().fieldQ("Storageincluded").bin({bin: true, step: 8}),
vl.y().count(),
) .render()
Insert cell
Insert cell
vl.markBar()
.data(data)
.encode(
vl.x().fieldQ("Effectivepixels").bin({bin: true, step: 2}),
vl.y().count(),
) .render()
Insert cell
Insert cell
vl.markBar()
.data(data.filter(d => d.Weight > 0))
.encode(
vl.x().fieldQ("Weight").bin({bin: true, step: 50}),
vl.y().count(),
) .render()
Insert cell
Insert cell
vl.markBar()
.data(data.filter(d => d.Price < 2000))
.encode(
vl.x().fieldQ("Price").bin({bin: true, step: 50}),
vl.y().count(),
) .render()
Insert cell
Insert cell
vl.markBar()
.data(data.filter(d => d.Maxresolution > 0))
.encode(
vl.x().fieldQ("Maxresolution").bin({bin: true, step: 500}),
vl.y().count(),
) .render()
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