The Complete Trend Report
Advanced · Write the code · from Time Series: Detect Trends and Anomalies in Business Data
From the lesson: Step 6: Generate a Complete Trend Report
A good analysis ends with a clear summary. Decision-makers don't want to see raw DataFrames - they want insights. Let's pull together everything we've built into a single comprehensive trend report.
Read this part of the lessonWrite a function generate_report(df) that takes the sales DataFrame and prints a complete analysis report:
1. "=== SALES TREND REPORT ===" header
2. Overview: date range, total days, total revenue, mean daily sales
3. Trend: first vs last week average, percentage change, direction (UPWARD/DOWNWARD)
4. Weekly Pattern: best and worst day of week
5. Anomalies: count of days with |z-score| > 1.5
6. A final "Recommendation:" line based on the trend direction
Call it with the generated DataFrame.
More Time Series exercises
- Build the Time Series DataFrameAdvanced
- Compute Moving AveragesAdvanced
- Measure the TrendAdvanced
- Discover Seasonal PatternsAdvanced
- Flag Anomalous DaysAdvanced
All Python exercises · 50 practice problems · Practical Projects quiz