Download app.py from alyasltd/datasets: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/spaces/alyasltd/datasets/resolve/main/app.py
- Command line
-
hf download hf://spaces/alyasltd/datasets/app.py
-
curl -L -o app.py https://huggingface.co/spaces/alyasltd/datasets/resolve/main/app.py
3.66 kB
| import streamlit as st | |
| import pandas as pd | |
| import plotly.express as px | |
| import random | |
| import plotly.graph_objects as go | |
| import streamlit.components.v1 as components | |
| import requests | |
| import numpy as np | |
| from streamlit_lottie import st_lottie | |
| st.set_page_config(layout="wide") | |
| def load_lottie_url(url: str): | |
| r = requests.get(url) | |
| if r.status_code != 200: | |
| return None | |
| return r.json() | |
| # Chargement des données | |
| # Fonction pour charger les différents datasets | |
| def load_data(): | |
| # Chemins des fichiers | |
| path_complete = r'cleaned_merged_data.csv' | |
| path_opinions = r'opinions.csv' | |
| # Chargement du dataset complet | |
| df_complete = pd.read_csv(path_complete) | |
| df_complete.dropna(inplace=True) # Nettoyage des données, si nécessaire | |
| # Chargement du dataset des opinions | |
| df_opinions = pd.read_csv(path_opinions) | |
| df_opinions.dropna(inplace=True) # Nettoyage des données, si nécessaire | |
| return df_complete, df_opinions | |
| # Chargement des trois instances de dataframe | |
| df, df_opinions = load_data() | |
| # CSS personnalisé | |
| custom_css = """ | |
| <style> | |
| /* Personnaliser les titres */ | |
| .block-container { | |
| padding-top: 1rem; | |
| padding-bottom: 0rem; | |
| padding-left: 5rem; | |
| padding-right: 5rem; | |
| } | |
| h1 { | |
| color: #002c4d; | |
| } | |
| [data-testid="stDecoration"] { | |
| display: none; | |
| } | |
| h2 { | |
| color: #002c4d; | |
| border-bottom: 2px solid #002c4d; | |
| } | |
| /* Personnaliser le bouton */ | |
| .stButton button { | |
| background-color: #002c4d !important; | |
| color: white !important; | |
| border-radius: 5px !important; | |
| border: none !important; | |
| padding: 8px 15px !important; | |
| font-size: 16px !important; | |
| } | |
| /* Personnaliser le fond */ | |
| body { | |
| background-color: white !important; | |
| } | |
| /* Ajouter plus de padding-top aux paragraphes */ | |
| .custom-paragraph { | |
| padding-top: 20px; | |
| } | |
| </style> | |
| """ | |
| # Injecter le CSS personnalisé dans l'application | |
| st.markdown(custom_css, unsafe_allow_html=True) | |
| coll1,coll2,coll3= st.columns([1,4,1]) | |
| with coll2: | |
| col1,col2= st.columns([2,5]) | |
| with col1: | |
| lottie_animation_1 = "https://assets1.lottiefiles.com/packages/lf20_5mhyg2hz.json" | |
| lottie_anime_json = load_lottie_url(lottie_animation_1) | |
| st_lottie(lottie_anime_json, key="logo") | |
| with col2: | |
| for _ in range(3): # Ajustez le nombre de lignes selon le besoin | |
| st.write("") | |
| st.title('Explore Our Datasets') | |
| # Titre principal et introduction | |
| st.header('Description of our Data') | |
| st.write(" ") | |
| st.write(""" | |
| The data presented here were used in our TER project, focused on analyzing the controversy on Twitter. They allowed us to perform various analyses such as: | |
| - Sentiment and emotion analysis: to understand user reactions. | |
| - Social network analysis: to capture the links between hashtags and tweet clusters based on LDA analysis. | |
| - Statistical analysis: which allowed us to connect our previous work through the controversy index, which attempts to quantify the level of controversy of a tweet.""") | |
| # Affichage des datasets | |
| # Vous pouvez remplacer 'df', 'df_opinions', et 'df_controversy_index' par vos variables de dataframe réelles | |
| st.header('Check our Datasets !') | |
| # Ajouter un sélecteur pour le dataset à afficher | |
| dataset_choice = st.selectbox('Select the dataset you want to view:', | |
| ['Complete Dataset', 'Opinions Dataset']) | |
| if dataset_choice == 'Complete Dataset': | |
| st.subheader('Complete Dataset') | |
| st.dataframe(df) | |
| elif dataset_choice == 'Opinions Dataset': | |
| st.subheader('Opinions Dataset') | |
| st.dataframe(df_opinions) | |