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 ...