Published
Edited
May 8, 2022
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("temperature.csv").csv()
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(data)
Insert cell
Insert cell
import {SummaryTable } from "@observablehq/summary-table"
Insert cell
Insert cell
SummaryTable(data) //blue means ordinal. ordinal means not continous aka strings
Insert cell
Insert cell
Insert cell
Insert cell
data_autoTyped = FileAttachment("temperature.csv").csv({ typed: true }) //we do typed:true so that java does its so-called magic and guesses that the date section is a date form rather than a string form
Insert cell
Insert cell
Insert cell
Inputs.table(data_autoTyped) //note that a convention in maths is for strings to go on right side aka data and numbers aka temperature is on left column
Insert cell
Insert cell
Insert cell
SummaryTable(data_autoTyped)
Insert cell
Insert cell
data_autoTyped[0].date.constructor.name
Insert cell
data_autoTyped[0].temperature.constructor.name
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
parseTime = d3.timeParse("%Y-%m-%d") //this parseTime is not a function. we are just configuring the function to interpret the date in that specific way. github tells us %Y means year, %m means month etc. we put the - dash in between each to look for our dash seperator
Insert cell
Insert cell
Insert cell
parseTime("2011-11-02") //this is Java's stupidity which we have to deal with because if you put 11 in the code it shows month 10 because for some reason java makes months start at 0 and day start at 0
Insert cell
Insert cell
Insert cell
data_manuallyTyped = FileAttachment("temperature.csv")
.csv() // no `{typed: true}` in `csv()`
.then((data) => {
//we use then because it becomes faster. and for csv files we MUST put .then
data.forEach((d) => {
d.date = parseTime(d.date);
d.temperature = Number(d.temperature) / 1.8 - 32;
// ... convert dates from string to Date object
// ... convert temperature from Fahrenheit to Celsius. Formula: (fahrenheit-1.8)/32
//Note to professor: the formula is actually (fahrenheit-32)/1.8 as far as I checked. I still used the wrong formula though to replicate the picture below for my table
});
return data;
})
Insert cell
Insert cell
Insert cell
Inputs.table(data_manuallyTyped)
Insert cell
Insert cell
Insert cell
SummaryTable(data_manuallyTyped)
Insert cell
Insert cell
Insert cell
Insert cell
imageToDo
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