Commit
·
24f30c3
1
Parent(s):
e907431
V2-Liste_MAP_Stat_17
Browse files- statistiques.py +13 -2
statistiques.py
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
| 5 |
-
import matplotlib.pyplot as plt
|
| 6 |
from data_manager import get_data
|
| 7 |
from wordcloud import WordCloud, STOPWORDS
|
|
|
|
| 8 |
|
| 9 |
def display_companies_by_sector(df):
|
| 10 |
sector_counts = df['libelle_section_naf'].value_counts().reset_index()
|
|
@@ -20,12 +20,22 @@ def display_company_sizes(df):
|
|
| 20 |
fig.update_traces(marker_color='green')
|
| 21 |
st.plotly_chart(fig)
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
def display_rse_actions_wordcloud(df):
|
| 24 |
-
st.
|
| 25 |
|
| 26 |
custom_stopwords = set(["d ", "des", "qui", "ainsi", "toute", "hors", "plus", "cette", "afin", "via", "d'", "sa", "dans", "ont", "avec", "aux", "ce", "chez", "ont", "cela", "la", "un", "avons", "par", "c'est", "s'est", "aussi", "leurs", "d'un", "nos", "les", "sur", "ses", "tous", "nous", "du", "notre", "de", "et", "est", "pour", "le", "une", "se", "en", "au", "à", "que", "sont", "leur", "son"])
|
| 27 |
stopwords = STOPWORDS.union(custom_stopwords)
|
|
|
|
| 28 |
text = " ".join(action for action in df['action_rse'].dropna())
|
|
|
|
| 29 |
wordcloud = WordCloud(stopwords=stopwords, background_color="white", width=800, height=400).generate(text)
|
| 30 |
|
| 31 |
fig, ax = plt.subplots()
|
|
@@ -41,6 +51,7 @@ def main():
|
|
| 41 |
if not df.empty:
|
| 42 |
display_companies_by_sector(df)
|
| 43 |
display_company_sizes(df)
|
|
|
|
| 44 |
display_rse_actions_wordcloud(df)
|
| 45 |
|
| 46 |
if __name__ == "__main__":
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import pandas as pd
|
| 4 |
import plotly.express as px
|
|
|
|
| 5 |
from data_manager import get_data
|
| 6 |
from wordcloud import WordCloud, STOPWORDS
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
|
| 9 |
def display_companies_by_sector(df):
|
| 10 |
sector_counts = df['libelle_section_naf'].value_counts().reset_index()
|
|
|
|
| 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='Pourcentage d\'entreprises par Commune',
|
| 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):
|
| 32 |
+
st.header("Nuage de mots Actions RSE")
|
| 33 |
|
| 34 |
custom_stopwords = set(["d ", "des", "qui", "ainsi", "toute", "hors", "plus", "cette", "afin", "via", "d'", "sa", "dans", "ont", "avec", "aux", "ce", "chez", "ont", "cela", "la", "un", "avons", "par", "c'est", "s'est", "aussi", "leurs", "d'un", "nos", "les", "sur", "ses", "tous", "nous", "du", "notre", "de", "et", "est", "pour", "le", "une", "se", "en", "au", "à", "que", "sont", "leur", "son"])
|
| 35 |
stopwords = STOPWORDS.union(custom_stopwords)
|
| 36 |
+
|
| 37 |
text = " ".join(action for action in df['action_rse'].dropna())
|
| 38 |
+
|
| 39 |
wordcloud = WordCloud(stopwords=stopwords, background_color="white", width=800, height=400).generate(text)
|
| 40 |
|
| 41 |
fig, ax = plt.subplots()
|
|
|
|
| 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 |
|
| 57 |
if __name__ == "__main__":
|