Rolling mean and sum
📖 Scenario: You work as a data analyst for a small store. You have daily sales data for a week. Your manager wants to see the average and total sales over the last 3 days for each day to understand trends better.
🎯 Goal: Build a program that calculates the rolling mean and rolling sum of sales over a 3-day window using pandas.
📋 What You'll Learn
Create a pandas DataFrame with exact sales data for 7 days.
Set a window size variable for rolling calculations.
Calculate rolling mean and rolling sum using pandas.
Print the resulting DataFrame showing original sales, rolling mean, and rolling sum.
💡 Why This Matters
🌍 Real World
Rolling averages and sums help smooth out daily fluctuations in sales data, making it easier to spot trends and patterns over time.
💼 Career
Data analysts and scientists often use rolling calculations to analyze time series data in finance, sales, weather, and many other fields.
Progress0 / 4 steps