Public
Edited
Sep 28, 2023
1 star
Insert cell
Insert cell
Insert cell
input_file = {
// Source file:
// https://www.regionalstatistik.de/genesis/online?operation=download&code=61511-01-03-4-B&regionalschluessel=09162,11000,02000&zeitscheiben=10&option=ffcsv
const fileBuffer = await FileAttachment("61511-01-03-4-B_flat.csv").arrayBuffer()
// Source file is encoded using ISO 8859-1 / Windows-1252:
const windows1252 = new TextDecoder('windows-1252')
return windows1252.decode(fileBuffer)
}
Insert cell
Insert cell
// Source file uses semicolons as delimiters and commas as decimal separators
input_data = aq.fromCSV(input_file, { delimiter: ';', decimal: ','})
Insert cell
Insert cell
Insert cell
table = input_data
.filter(d => d['2_Auspraegung_Label'] === 'Insgesamt')
.select({
'1_Auspraegung_Label': 'city',
'Zeit': 'year',
'BAU004__Durchschnittlicher_Kaufwert_je_qm__EUR': 'value'
})
Insert cell
Insert cell
Insert cell
pivoted_table = table
.groupby('year')
.pivot('city', 'value')
Insert cell
Insert cell
Insert cell
[...pivoted_table]
Insert cell
vegalite({
data: {values: [...table]},
mark: "line",
encoding: {
x: {field: "year"},
y: {field: "value", type: "quantitative"},
color: {field: "city", type: "nominal"}
}
})
Insert cell
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