Unlisted
Edited
Sep 4, 2024
Insert cell
Insert cell
// Create a database client
client = DuckDBClient.of({
weather: FileAttachment("seattle-weather.parquet")
})
Insert cell
// Perform an UNPIVOT operation
client.query(`SELECT
"date" AS x,
value AS y,
key AS series
FROM
"weather" UNPIVOT (value FOR key IN ("temp_max", "temp_min"));`)
Insert cell
// Also doesn't seem to work with using the db directly
{
const db = client._db;
const conn = await db.connect();
const arrow = await conn.query(`SELECT
"date" AS x,
value AS y,
key AS series
FROM
"weather" UNPIVOT (value FOR key IN ("temp_max", "temp_min"));`);
return arrow.toArray();
}
Insert cell
import { DuckDBClient as DuckDBClient28 } from "@mkfreeman/duckdb-1-28";
Insert cell
client2 = DuckDBClient28.of({
weather: {
file: FileAttachment("seattle-weather.csv"),
delim: ",",
header: true
}
})
Insert cell
client3 = DuckDBClient28.of({
weather: seattleWeather
})
Insert cell
// Perform an UNPIVOT operation
client2.query(`SELECT
"date" AS x,
value AS y,
key AS series
FROM
"weather" UNPIVOT (value FOR key IN ("temp_max", "temp_min"));`)
Insert cell
// Perform an UNPIVOT operation
client3.query(`SELECT
"date" AS x,
value AS y,
key AS series
FROM
"weather" UNPIVOT (value FOR key IN ("temp_max", "temp_min"));`)
Insert cell
loadedData = FileAttachment("seattle-weather.csv").csv()
Insert cell
seattle-weather.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

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