thak123 commited on
Commit
a8ba682
·
verified ·
1 Parent(s): 027761a

Update index.py

Browse files
Files changed (1) hide show
  1. index.py +8 -0
index.py CHANGED
@@ -213,6 +213,14 @@ app.layout = dbc.Container([
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
  # filter dataframes based on updated data range
218
  mask_1 = ((df["Topic"] == selected_topic) & (df['date'] >= start_date) & (df['date'] <= end_date))
 
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 ) else 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))