Published
Edited
May 17, 2021
1 fork
4 stars
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
agregats = {
//dézippage et extraction des données valides (France métro, non nulles...), puis
/*const dt0 = aq.fromCSV( await fetch_txtfile_from_zip(insee_csv_zipped,
null, //extrait le 1er fichier trouvé dans le zip
{proxy: true}), //utilise un proxy pour ouvrir l'accès CORS
{delimiter: ";"} ) */
//const dt0 = ( await aq.loadCSV(insee_csv_url) )
const dt0 = ( aq.fromCSV(await FileAttachment('retro11.csv').text(), {delimiter:';'}) )
.filter(d => d.LNCONJ == "TOTAL"
&& d.CHAMP =='FM' // France métropolitaine seulement (série depuis 1946)
&& d.NBMAR !== 'so' // éliminer les valeurs manquantes, sans objet
&& d.NBMAR !== null)
const dt = dt0
.groupby('ANNEE_1946_2018','MOIS')
.rollup({NBMAR: op.sum('NBMAR')}) //agrégation sur tous les types de mariage : HF, HH et FF
const dt1 = dt.filter(d => d.MOIS == 'AN') // extraction du total annuel
.select({'ANNEE_1946_2018': 'AN', 'NBMAR': 'TOT'}) //renommage de variables
.reify() // ****
const dt2 = dt.filter(d => d.MOIS != 'AN') // extraction des données mensuelles
.select({'ANNEE_1946_2018': 'AN'}, 1, 2)

const dt3 = dt2.join_left(dt1) //***jointure pour calculer le % dans le total annuel
.derive({ date: d => op.utcdatetime(d.AN, d.MOIS, 0),
PCT : d => 100 * d.NBMAR / d.TOT})
.relocate('PCT', {after: 3})
.orderby(0, 1)
return {total_annuel: dt1, detail_mensuel: dt3, detail_mensuel_typmar: dt0}
}
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
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