Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,12 +14,11 @@ df['Date'] = pd.to_datetime(df['Date'])
|
|
| 14 |
df['Month'] = df['Date'].dt.to_period('M')
|
| 15 |
df['Day'] = df['Date'].dt.date
|
| 16 |
|
| 17 |
-
|
| 18 |
# --- GRADIO FUNCTION ---
|
| 19 |
def show_sentiment(selected_companies, aggregation="Day"):
|
| 20 |
# filtraggio aziende
|
| 21 |
if selected_companies:
|
| 22 |
-
df_filtered = df[df['Company'].isin(selected_companies)]
|
| 23 |
else:
|
| 24 |
df_filtered = df.copy()
|
| 25 |
|
|
@@ -28,6 +27,8 @@ def show_sentiment(selected_companies, aggregation="Day"):
|
|
| 28 |
group_col = "Day"
|
| 29 |
elif aggregation == "Month":
|
| 30 |
group_col = "Month"
|
|
|
|
|
|
|
| 31 |
elif aggregation == "Year":
|
| 32 |
group_col = "Year"
|
| 33 |
else:
|
|
|
|
| 14 |
df['Month'] = df['Date'].dt.to_period('M')
|
| 15 |
df['Day'] = df['Date'].dt.date
|
| 16 |
|
|
|
|
| 17 |
# --- GRADIO FUNCTION ---
|
| 18 |
def show_sentiment(selected_companies, aggregation="Day"):
|
| 19 |
# filtraggio aziende
|
| 20 |
if selected_companies:
|
| 21 |
+
df_filtered = df[df['Company'].isin(selected_companies)].copy()
|
| 22 |
else:
|
| 23 |
df_filtered = df.copy()
|
| 24 |
|
|
|
|
| 27 |
group_col = "Day"
|
| 28 |
elif aggregation == "Month":
|
| 29 |
group_col = "Month"
|
| 30 |
+
# Convertiamo Period in datetime per Plotly
|
| 31 |
+
df_filtered['Month'] = df_filtered['Month'].dt.to_timestamp()
|
| 32 |
elif aggregation == "Year":
|
| 33 |
group_col = "Year"
|
| 34 |
else:
|