Plotting time series data
In trying to boost purchases, we have made some changes to our introductory in-app purchase pricing. In this exercise, you will check if this is having an impact on the number of purchases made by purchasing users during their first week.
The dataset user_purchases
has been joined to the demographics data and properly filtered. The column 'first_week_purchases'
that is 1 for a first week purchase and 0 otherwise has been added. This column is converted to the average number of purchases made per day by users in their first week.
We will try to view the impact of this change by looking at a graph of purchases as described in the instructions.
This exercise is part of the course
Customer Analytics and A/B Testing in Python
Exercise instructions
Read through and understand code shown and then plot the user_purchases
data with 'reg_date'
on the x-axis and 'first_week_purchases'
on the y-axis.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Group the data and aggregate first_week_purchases
user_purchases = user_purchases.groupby(by=['reg_date', 'uid']).agg({'first_week_purchases': ['sum']})
# Reset the indexes
user_purchases.columns = user_purchases.columns.droplevel(level=1)
user_purchases.reset_index(inplace=True)
# Find the average number of purchases per day by first-week users
user_purchases = user_purchases.groupby(by=['reg_date']).agg({'first_week_purchases': ['mean']})
user_purchases.columns = user_purchases.columns.droplevel(level=1)
user_purchases.reset_index(inplace=True)
# Plot the results
user_purchases.plot(x=____, y=____)
plt.show()