Rolling Aggregations on Time Series Data with Pandas

Alexander Mueller
6 min readDec 28, 2019
Photo by Markus Spiske on Unsplash

While writing this blog article, I took a break from working on lots of time series data with pandas. In the last weeks, I was performing lots of aggregation and feature engineering tasks on top of a credit card transaction dataset. I want to share with you some of my insights about useful operations for performing explorative data analysis or preparing a times series dataset for some machine learning tasks.

In this blog post you will learn:

  • How to load time series data from a CSV
  • What the rolling operation on a pandas dataframe is what is it useful for
  • How to combine group by operation and rolling operation on a pandas dataframe
  • Some examples for transformations using the two operations above that will be useful for you in practice
  • Some hints in how to parallelize these operations to be using all you CPU Cores.

(Hint you can find a Jupyter notebook containing all the code and the toy data mentioned in this blog post here)

Let us start by loading the data.

Loading Time Series data

Loading time series data from a CSV is straight forward in pandas. We simply use the read CSV command and define the Datetime column…

--

--

Alexander Mueller

AI Entrepreneur, Deep Learning & Python Enthusiast, Founder of workist