-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_4.py
More file actions
27 lines (24 loc) · 894 Bytes
/
Copy path_4.py
File metadata and controls
27 lines (24 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
import numpy as np
df = pd.read_csv('ENCDM_Menage_2014.csv')
focus_g5_g8 = {
# G5 - Équipement maison
'Meubles': 'DAP_G51',
'Textile_maison': 'DAP_G52',
'Gros_electromenag': 'DAP_G53',
# G8 - Loisirs culture
'Audio_video': 'DAP_G81',
'Livres_presse': 'DAP_G82',
'Vacances_tourisme': 'DAP_G83',
'Sport_loisirs': 'DAP_G84',
'Enseignement': 'DAP_G85',
}
print("=== G5 & G8 — Sous-catégories ===\n")
for label, col in focus_g5_g8.items():
if col in df.columns:
df[f'CB_{col}'] = df[col] / df['DAP'] * 100
means = df.groupby('Quintiles')[f'CB_{col}'].mean()
variation = means[5.0] - means[1.0]
direction = "↗" if variation > 0 else "↘"
print(f"{label:<20} Q1={means[1.0]:.2f}% Q5={means[5.0]:.2f}% "
f"Δ={variation:+.2f}% {direction}")