Spaces:
Sleeping
Sleeping
Update index.py
Browse files
index.py
CHANGED
@@ -248,13 +248,13 @@ def update_output(selected_topic, selected_domain, start_date, end_date):
|
|
248 |
date_range = pd.date_range(start=df_filtered['date'].min().date(), end=df_filtered['date'].max().date(), freq='MS')
|
249 |
|
250 |
# Create a MultiIndex with all combinations of date_range and all_media
|
251 |
-
idx = pd.MultiIndex.from_product([date_range, all_media], names=['
|
252 |
|
253 |
# Reindex the DataFrame to include all periods and media
|
254 |
-
grouped_df = grouped_df.set_index(['
|
255 |
|
256 |
-
bar_fig_1 = px.bar(grouped_df, x='
|
257 |
-
labels={'
|
258 |
title='Número de notícias por período de tempo')
|
259 |
bar_fig_1.update_xaxes(tickformat="%b %d<br>%Y")
|
260 |
# Bar Graph ends
|
|
|
248 |
date_range = pd.date_range(start=df_filtered['date'].min().date(), end=df_filtered['date'].max().date(), freq='MS')
|
249 |
|
250 |
# Create a MultiIndex with all combinations of date_range and all_media
|
251 |
+
idx = pd.MultiIndex.from_product([date_range, all_media], names=['period', 'Veículos de notícias'])
|
252 |
|
253 |
# Reindex the DataFrame to include all periods and media
|
254 |
+
grouped_df = grouped_df.set_index(['period', 'Veículos de notícias']).reindex(idx, fill_value=0).reset_index()
|
255 |
|
256 |
+
bar_fig_1 = px.bar(grouped_df, x='period', y='occurrences', color='Veículos de notícias',
|
257 |
+
labels={'period': 'Período', 'occurrences': 'Número de notícias', 'Veículos de notícias': 'Portal'},
|
258 |
title='Número de notícias por período de tempo')
|
259 |
bar_fig_1.update_xaxes(tickformat="%b %d<br>%Y")
|
260 |
# Bar Graph ends
|