Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -178,13 +178,16 @@ with gr.Blocks() as app:
|
|
178 |
return pd.DataFrame(), "β οΈ Date could not be parsed.", None
|
179 |
|
180 |
if report_type == "Daily":
|
|
|
181 |
mask = df['Date'] == str(date_obj.date())
|
182 |
elif report_type == "Weekly":
|
183 |
start = date_obj - pd.Timedelta(days=date_obj.weekday())
|
184 |
end = start + pd.Timedelta(days=6)
|
185 |
-
|
|
|
186 |
elif report_type == "Monthly":
|
187 |
-
|
|
|
188 |
|
189 |
filtered = df[mask]
|
190 |
|
@@ -197,6 +200,7 @@ with gr.Blocks() as app:
|
|
197 |
]].sort_values(by=["Rep Name", "Date"])
|
198 |
|
199 |
insights = f"""
|
|
|
200 |
### π Insights:
|
201 |
- **Total Visits:** {len(filtered)}
|
202 |
- **Unique Reps:** {filtered['Rep Name'].nunique()}
|
|
|
178 |
return pd.DataFrame(), "β οΈ Date could not be parsed.", None
|
179 |
|
180 |
if report_type == "Daily":
|
181 |
+
title = f"π Report for {date_obj.strftime('%B %d, %Y')}"
|
182 |
mask = df['Date'] == str(date_obj.date())
|
183 |
elif report_type == "Weekly":
|
184 |
start = date_obj - pd.Timedelta(days=date_obj.weekday())
|
185 |
end = start + pd.Timedelta(days=6)
|
186 |
+
title = f"π Week of {start.strftime('%b %d')} β {end.strftime('%b %d')}, {start.year}"
|
187 |
+
mask = (pd.to_datetime(df['Date']) >= start) & (pd.to_datetime(df['Date']) <= end)
|
188 |
elif report_type == "Monthly":
|
189 |
+
title = f"π Report for {date_obj.strftime('%B %Y')}"
|
190 |
+
mask = pd.to_datetime(df['Date']).dt.to_period("M") == pd.to_datetime(date_obj).to_period("M")
|
191 |
|
192 |
filtered = df[mask]
|
193 |
|
|
|
200 |
]].sort_values(by=["Rep Name", "Date"])
|
201 |
|
202 |
insights = f"""
|
203 |
+
### {title}
|
204 |
### π Insights:
|
205 |
- **Total Visits:** {len(filtered)}
|
206 |
- **Unique Reps:** {filtered['Rep Name'].nunique()}
|