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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more