Pandas for Productivity Vlog Ep 5: Moving averages in Pandas

Why this topic?

This topic doesn’t have much documentation, yet is potentially very useful. Calculating moving averages in Excel is time-consuming. Furthermore, when you use a window function in SQL you must structure the query carefully. Why not do it in Pandas instead?

What it covers:

First, I demonstrate how to use .rolling() to get a 7-day moving average of daily new COVID-19 cases. Next, I show how to use 3 other features of the .rolling method:

  • Using an offset instead of an integer window
  • The “min_periods” keyword argument
  • “Closed” keyword argument

Watch it here:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.