When we want to predict an event at a certain point in time, often, transactions or values closer to the event tend to be more relevant. Then, if we want to predict whether a customer will churn next week, the information in the last weeks or months tends to be more informative than the transactions of the customer in the past 5 years.
We can use mathematical operations to summarize historical data, just like we did in the previous recipe, but only for a certain temporal window. This way, we can create features such as the maximum amount spent in the last week or the number of transactions in the last month, to name a few examples. In this recipe, we will summarize time series data over discrete time windows using pandas.