Public
Edited
Jul 17, 2023
29 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
db = DuckDBClient.of({
prenoms2021: FileAttachment("prenoms2021_f.parquet"),
dept: {
file: FileAttachment("dep2021.csv"),
header: true
},
reg: {
file: FileAttachment("reg2021.csv"),
header: true
}
})
Insert cell
db.query('describe table dept')
Insert cell
Insert cell
viewof extrait = {
const data = await db.query(`SELECT * FROM prenoms2021
WHERE preusuel <> '_PRENOMS_RARES' AND annais <> 'XXXX'
USING SAMPLE 100`)
// backticks ` allow to write a SQL query on several lines
// Writing SQL verbs in uppercase is not mandatory, but it's prettier!
return Inputs.table(data, {height: 200, layout: "auto", maxWidth: 500})
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const data = await db.query(
`SELECT reg || ' - '|| libgeo AS Region, arg_max(preusuel, nombre) as 'Most popular' FROM
( SELECT reg, preusuel, SUM(nombre) AS nombre
FROM prenoms2021 left join (SELECT codgeo, libgeo, lpad(reg, 2, '0') AS reg FROM dept) d
ON prenoms2021.dpt = d.codgeo
WHERE annais = ? AND sexe = ? AND preusuel <> '_PRENOMS_RARES'
GROUP BY ALL
) p LEFT JOIN reg ON p.reg = reg.codgeo
GROUP BY ALL ORDER BY ALL`,
[annais_reg, sexe_reg])

return Inputs.table(data.map(d => d.toJSON())
.map(d => {d['Most popular'] = getTitleCase(d['Most popular']); return d}), {height: 440, layout: "auto", maxWidth: 400})
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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