...
/Data Exploration: Customer Revenue Analysis
Data Exploration: Customer Revenue Analysis
Learn about more data exploration and visualization techniques using pandas, Matplotlib, and Seaborn libraries.
In this lesson, we’ll continue our exploration of the online transaction dataset. We’ll transform the dataset for cohort analysis by grouping customers who made their first purchase in the same month.
Aggregate monthly transactions
Let's prepare the base and aggregate month-over-month total sales for each customer.
Press + to interact
# aggregate monthly revenue for each customerdf_monthly_sales = df_cdnow_tr.groupby(['customer_id', 'year_month']).agg({'price': 'sum'})df_monthly_sales.reset_index(inplace=True)print(df_monthly_sales.head())
Explanation
In line 2, we ...