Spaces:
Sleeping
Sleeping
Update index.py
Browse files
index.py
CHANGED
@@ -14,6 +14,12 @@ from datetime import date
|
|
14 |
import dash_bootstrap_components as dbc
|
15 |
import plotly.express as px
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
server = app.server
|
18 |
|
19 |
url='https://drive.google.com/file/d/1NaXOYHQFF5UO5rQr4rn8Lr3bkYMSOq4_/view?usp=sharing'
|
@@ -212,15 +218,17 @@ app.layout = dbc.Container([
|
|
212 |
)
|
213 |
def update_output(selected_topic, selected_domain, start_date, end_date):
|
214 |
#log
|
215 |
-
print("topic:",selected_topic,"domain:",selected_domain,"start:", start_date,"end:", end_date)
|
216 |
|
217 |
# This is a hack to filter dates to confine to respective topic boundaries
|
218 |
min_topic_date = df[df["Topic"] == selected_topic]["date"].min()
|
219 |
max_topic_date = df[df["Topic"] == selected_topic]["date"].max()
|
220 |
|
221 |
#if start visualisation from where the topic starts
|
222 |
-
start_date = min_topic_date if (min_topic_date > start_date) else start_date
|
223 |
-
end_date = max_topic_date if (max_topic_date < end_date
|
|
|
|
|
224 |
|
225 |
# filter dataframes based on updated data range
|
226 |
mask_1 = ((df["Topic"] == selected_topic) & (df['date'] >= start_date) & (df['date'] <= end_date))
|
|
|
14 |
import dash_bootstrap_components as dbc
|
15 |
import plotly.express as px
|
16 |
|
17 |
+
|
18 |
+
from dateutil.parser import parse
|
19 |
+
|
20 |
+
def convert_to_datetime(input_str, parserinfo=None):
|
21 |
+
return parse(input_str, parserinfo=parserinfo)
|
22 |
+
|
23 |
server = app.server
|
24 |
|
25 |
url='https://drive.google.com/file/d/1NaXOYHQFF5UO5rQr4rn8Lr3bkYMSOq4_/view?usp=sharing'
|
|
|
218 |
)
|
219 |
def update_output(selected_topic, selected_domain, start_date, end_date):
|
220 |
#log
|
221 |
+
print("topic:",selected_topic,"domain:",selected_domain,"start:", start_date,"end:", end_date,"\n\n")
|
222 |
|
223 |
# This is a hack to filter dates to confine to respective topic boundaries
|
224 |
min_topic_date = df[df["Topic"] == selected_topic]["date"].min()
|
225 |
max_topic_date = df[df["Topic"] == selected_topic]["date"].max()
|
226 |
|
227 |
#if start visualisation from where the topic starts
|
228 |
+
start_date = min_topic_date.dt.date if (min_topic_date > convert_to_datetime(start_date)) else start_date
|
229 |
+
end_date = max_topic_date.dt.date if (max_topic_date < convert_to_datetime(end_date)) else end_date
|
230 |
+
|
231 |
+
print("After: Sd",start_date,"Ed",end_date)
|
232 |
|
233 |
# filter dataframes based on updated data range
|
234 |
mask_1 = ((df["Topic"] == selected_topic) & (df['date'] >= start_date) & (df['date'] <= end_date))
|