SuhasGholkar commited on
Commit
48afa38
·
verified ·
1 Parent(s): f392bf8

Update eda.py

Browse files
Files changed (1) hide show
  1. eda.py +5 -2
eda.py CHANGED
@@ -497,9 +497,12 @@ def render_eda():
497
  review_kw = st.session_state.eda_filters["review_kw"]
498
 
499
  # Filter frames
500
- orders_monthly_all = data.get("orders_monthly", pd.DataFrame())
501
  if not orders_monthly_all.empty and "month" in orders_monthly_all.columns:
502
- orders_monthly_f = orders_monthly_all[(orders_monthly_all["month"] >= start_dt) & (orders_monthly_all["month"] <= end_dt)].copy()
 
 
 
503
  else:
504
  orders_monthly_f = pd.DataFrame(columns=["month","count"])
505
 
 
497
  review_kw = st.session_state.eda_filters["review_kw"]
498
 
499
  # Filter frames
500
+ # Use the already parsed monthly frame above; coerce type defensively and drop NaT before comparing
501
  if not orders_monthly_all.empty and "month" in orders_monthly_all.columns:
502
+ if not pd.api.types.is_datetime64_any_dtype(orders_monthly_all["month"]):
503
+ orders_monthly_all["month"] = pd.to_datetime(orders_monthly_all["month"], errors="coerce").dt.floor("D")
504
+ _om = orders_monthly_all.dropna(subset=["month"])
505
+ orders_monthly_f = _om[(_om["month"] >= start_dt) & (_om["month"] <= end_dt)].copy()
506
  else:
507
  orders_monthly_f = pd.DataFrame(columns=["month","count"])
508