Commit
·
97e81fe
1
Parent(s):
24f30c3
V2-Liste_MAP_Stat_18
Browse files- statistiques.py +9 -4
statistiques.py
CHANGED
|
@@ -9,23 +9,25 @@ import matplotlib.pyplot as plt
|
|
| 9 |
def display_companies_by_sector(df):
|
| 10 |
sector_counts = df['libelle_section_naf'].value_counts().reset_index()
|
| 11 |
sector_counts.columns = ['Secteur', 'Nombre']
|
| 12 |
-
fig = px.bar(sector_counts, x='Secteur', y='Nombre', title="
|
| 13 |
color='Nombre', labels={'Nombre':'Nombre d\'entreprises'}, template='plotly_white')
|
| 14 |
-
fig.update_layout(xaxis_tickangle=-45)
|
| 15 |
st.plotly_chart(fig)
|
| 16 |
|
| 17 |
def display_company_sizes(df):
|
| 18 |
-
fig = px.histogram(df, x='tranche_effectif_entreprise', title="
|
| 19 |
labels={'tranche_effectif_entreprise':'Taille de l\'entreprise'}, template='plotly_white')
|
| 20 |
fig.update_traces(marker_color='green')
|
|
|
|
| 21 |
st.plotly_chart(fig)
|
| 22 |
|
| 23 |
def display_companies_by_commune(df):
|
| 24 |
commune_counts = df['commune'].value_counts(normalize=True).reset_index()
|
| 25 |
commune_counts.columns = ['Commune', 'Pourcentage']
|
| 26 |
-
fig = px.pie(commune_counts, values='Pourcentage', names='Commune', title='
|
| 27 |
template='plotly_white', hole=.3)
|
| 28 |
fig.update_traces(textinfo='percent+label')
|
|
|
|
| 29 |
st.plotly_chart(fig)
|
| 30 |
|
| 31 |
def display_rse_actions_wordcloud(df):
|
|
@@ -49,8 +51,11 @@ def main():
|
|
| 49 |
df = pd.DataFrame(data)
|
| 50 |
|
| 51 |
if not df.empty:
|
|
|
|
| 52 |
display_companies_by_sector(df)
|
|
|
|
| 53 |
display_company_sizes(df)
|
|
|
|
| 54 |
display_companies_by_commune(df)
|
| 55 |
display_rse_actions_wordcloud(df)
|
| 56 |
|
|
|
|
| 9 |
def display_companies_by_sector(df):
|
| 10 |
sector_counts = df['libelle_section_naf'].value_counts().reset_index()
|
| 11 |
sector_counts.columns = ['Secteur', 'Nombre']
|
| 12 |
+
fig = px.bar(sector_counts, x='Secteur', y='Nombre', title="",
|
| 13 |
color='Nombre', labels={'Nombre':'Nombre d\'entreprises'}, template='plotly_white')
|
| 14 |
+
fig.update_layout(xaxis_tickangle=-45, title_text="Répartition des entreprises par secteur d'activité", title_x=0.5)
|
| 15 |
st.plotly_chart(fig)
|
| 16 |
|
| 17 |
def display_company_sizes(df):
|
| 18 |
+
fig = px.histogram(df, x='tranche_effectif_entreprise', title="",
|
| 19 |
labels={'tranche_effectif_entreprise':'Taille de l\'entreprise'}, template='plotly_white')
|
| 20 |
fig.update_traces(marker_color='green')
|
| 21 |
+
fig.update_layout(title_text="Distribution des tailles d'entreprises", title_x=0.5)
|
| 22 |
st.plotly_chart(fig)
|
| 23 |
|
| 24 |
def display_companies_by_commune(df):
|
| 25 |
commune_counts = df['commune'].value_counts(normalize=True).reset_index()
|
| 26 |
commune_counts.columns = ['Commune', 'Pourcentage']
|
| 27 |
+
fig = px.pie(commune_counts, values='Pourcentage', names='Commune', title='',
|
| 28 |
template='plotly_white', hole=.3)
|
| 29 |
fig.update_traces(textinfo='percent+label')
|
| 30 |
+
fig.update_layout(title_text="Pourcentage d'entreprises par Commune", title_x=0.5)
|
| 31 |
st.plotly_chart(fig)
|
| 32 |
|
| 33 |
def display_rse_actions_wordcloud(df):
|
|
|
|
| 51 |
df = pd.DataFrame(data)
|
| 52 |
|
| 53 |
if not df.empty:
|
| 54 |
+
st.header("Répartition des entreprises par secteur d'activité")
|
| 55 |
display_companies_by_sector(df)
|
| 56 |
+
st.header("Distribution des tailles d'entreprises")
|
| 57 |
display_company_sizes(df)
|
| 58 |
+
st.header("Pourcentage d'entreprises par Commune")
|
| 59 |
display_companies_by_commune(df)
|
| 60 |
display_rse_actions_wordcloud(df)
|
| 61 |
|