Public
Edited
Jul 19, 2023
4 forks
Importers
20 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
Insert cell
viewof extrait = {
const data = await db.query(`SELECT * FROM prenoms2021
WHERE preusuel <> '_PRENOMS_RARES' AND annais <> 'XXXX'
USING SAMPLE 100`)
// L'usage des backticks `` permet d'écrire une requête SQL sur plusieurs lignes
// Écrire les verbes SQL en majuscules n'est pas obligatoire, mais c'est plus joli !
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 Région, arg_max(preusuel, nombre) as '1er prénom' 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['1er prénom'] = getTitleCase(d['1er prénom']); 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
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