Trending items over time

So far, we have analyzed the overall time series patterns and how customers engage with the overall business, but not how customers engage with individual products. In this section, we are going to explore and analyze how customers interact with individual products that are sold. More specifically, we will take a look at the trends of the top five best-sellers over time.

For time series trending-item analysis, let's count the number of items sold for each product for each period. Take a look at the following code:

date_item_df = df.set_index('InvoiceDate').groupby([    pd.Grouper(freq='M'), 'StockCode'])['Quantity'].sum()

As you can see from this code snippet, we are grouping the DataFrame, df, by month with StockCode ...

Get Hands-On Data Science for Marketing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.