Spaces:
Sleeping
Sleeping
Update index.py
Browse files
index.py
CHANGED
@@ -154,7 +154,46 @@ def update_output(selected_topic, start_date, end_date):
|
|
154 |
#set label format on y-axis in line graphs
|
155 |
line_fig_1.update_xaxes(tickformat="%b %d<br>%Y")
|
156 |
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
|
160 |
|
|
|
154 |
#set label format on y-axis in line graphs
|
155 |
line_fig_1.update_xaxes(tickformat="%b %d<br>%Y")
|
156 |
|
157 |
+
# filter dataframes based on updated data range
|
158 |
+
mask_2 = ((df_pos["Topic"] == selected_topic) & (df_pos["domain_folder_name"] == selected_domain) & (df_pos['date'] >= start_date) & (df_pos['date'] <= end_date))
|
159 |
+
mask_3 = ((df_neu["Topic"] == selected_topic) & (df_neu["domain_folder_name"] == selected_domain) & (df_neu['date'] >= start_date) & (df_neu['date'] <= end_date))
|
160 |
+
mask_4 = ((df_neg["Topic"] == selected_topic) & (df_neg["domain_folder_name"] == selected_domain) & (df_neg['date'] >= start_date) & (df_neg['date'] <= end_date))
|
161 |
+
df2_filtered = df_pos.loc[mask_2]
|
162 |
+
df3_filtered = df_neu.loc[mask_3]
|
163 |
+
df4_filtered = df_neg.loc[mask_4]
|
164 |
+
|
165 |
+
#create line graphs based on filtered dataframes
|
166 |
+
line_fig_2 = px.line(df2_filtered, x="date", y="rolling_mean_counts", line_group="FinBERT_label",
|
167 |
+
title="Positive")
|
168 |
+
line_fig_3 = px.line(df3_filtered, x="date", y="rolling_mean_counts", line_group="FinBERT_label",
|
169 |
+
title="Neutral")
|
170 |
+
line_fig_4 = px.line(df4_filtered, x="date", y="rolling_mean_counts", line_group="FinBERT_label",
|
171 |
+
title="Negative")
|
172 |
+
|
173 |
+
#set x-axis title and y-axis title in line graphs
|
174 |
+
line_fig_2.update_layout(
|
175 |
+
xaxis_title='Data',
|
176 |
+
yaxis_title='Número de notícias com sentimento positivo')
|
177 |
+
line_fig_3.update_layout(
|
178 |
+
xaxis_title='Data',
|
179 |
+
yaxis_title='Número de notícias com sentimento neutro')
|
180 |
+
line_fig_4.update_layout(
|
181 |
+
xaxis_title='Data',
|
182 |
+
yaxis_title='Número de notícias com sentimento negativo')
|
183 |
+
|
184 |
+
#set label format on y-axis in line graphs
|
185 |
+
line_fig_2.update_xaxes(tickformat="%b %d<br>%Y")
|
186 |
+
line_fig_3.update_xaxes(tickformat="%b %d<br>%Y")
|
187 |
+
line_fig_4.update_xaxes(tickformat="%b %d<br>%Y")
|
188 |
+
|
189 |
+
#set label format on y-axis in line graphs
|
190 |
+
line_fig_2.update_traces(line_color='#1E88E5')
|
191 |
+
line_fig_3.update_traces(line_color='#004D40')
|
192 |
+
line_fig_4.update_traces(line_color='#D81B60')
|
193 |
+
|
194 |
+
return line_fig_1, line_fig_2, line_fig_3, line_fig_4
|
195 |
+
|
196 |
+
# return line_fig_1
|
197 |
|
198 |
|
199 |
|