From the course: Data Analysis with Python and Pandas

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Aggregation and resampling

Aggregation and resampling

- [Instructor] All right, so let's take a look at time series aggregation. We can aggregate time series using the groupby method, but depending on our use case, we're going to show you a better method. But let's take a look at this with the groupby method first. So here we have our sales series. We have a bunch of dates and we have a bunch of sales as our values. And here we're accessing the month portion of our date to get a sum of sales by month. And note that this is going to calculate the total sales by month regardless of the year. So this is something we need to be careful about with traditional aggregation. We're not going to be grouping by calendar month. We're going to be grouping by any year that has a specific month. So we're grabbing values from January, 2022 and January, 2023 when we group like this. So in order to make sure we keep our year distinct, we need to specify grouping by both year and month. We could also group by year, which would just calculate the total…

Contents