File size: 2,791 Bytes
9157013 e907431 24f30c3 9157013 4034b79 9157013 871ab39 cc6bd0f 4445cc9 cc6bd0f 9157013 cc6bd0f 9157013 871ab39 4445cc9 9157013 4445cc9 9157013 24f30c3 871ab39 24f30c3 9157013 24f30c3 80f2f60 4445cc9 62ad8c1 24f30c3 80f2f60 24f30c3 62ad8c1 80f2f60 62ad8c1 80f2f60 3214d01 9157013 e907431 97e81fe 3bcbf53 97e81fe 3bcbf53 97e81fe 24f30c3 3bcbf53 e907431 9157013 |
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# statistiques.py
import streamlit as st
import pandas as pd
import plotly.express as px
from data_manager import get_data
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
def display_companies_by_sector(df):
sector_counts = df['libelle_section_naf'].value_counts().reset_index()
sector_counts.columns = ['Secteur', 'Nombre']
fig = px.bar(sector_counts, x='Secteur', y='Nombre',
color='Nombre', labels={'Nombre': ''}, template='plotly_white')
fig.update_layout(xaxis_tickangle=-45, showlegend=False)
# Assurez-vous que la légende est désactivée
fig.update_traces(showlegend=False)
st.plotly_chart(fig)
def display_company_sizes(df):
fig = px.histogram(df, x='tranche_effectif_entreprise',
labels={'tranche_effectif_entreprise':'Taille de l\'entreprise', 'count':'Nombre'}, template='plotly_white')
fig.update_traces(marker_color='green')
fig.update_layout(yaxis_title="Nombre")
st.plotly_chart(fig)
def display_companies_by_commune(df):
commune_counts = df['commune'].value_counts(normalize=True).reset_index()
commune_counts.columns = ['Commune', 'Pourcentage']
fig = px.pie(commune_counts, values='Pourcentage', names='Commune',
template='plotly_white', hole=.3)
fig.update_traces(textinfo='percent+label')
st.plotly_chart(fig)
def display_rse_actions_wordcloud(df):
st.header("Nuage de mots Actions RSE")
custom_stopwords = set(["l", "d", "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"])
stopwords = STOPWORDS.union(custom_stopwords)
text = " ".join(action for action in df['action_rse'].dropna())
wordcloud = WordCloud(stopwords=stopwords, background_color="white", width=800, height=400).generate(text)
fig, ax = plt.subplots()
ax.imshow(wordcloud, interpolation='bilinear')
ax.axis('off')
st.pyplot(fig)
def main():
st.title("Statistiques sur les entreprises engagées RSE")
data, _ = get_data()
df = pd.DataFrame(data)
if not df.empty:
st.header("Répartition des entreprises par secteur d'activité")
display_companies_by_sector(df)
st.header("Distribution des tailles d'entreprises")
display_company_sizes(df)
st.header("Pourcentage d'entreprises par Commune")
display_companies_by_commune(df)
display_rse_actions_wordcloud(df)
if __name__ == "__main__":
main()
|