Customer Analytics and A/B Testing in Python
Ryan Grossman
Data Scientist, EDO
Specific Goals:
General Concepts:
demographics_data = pd.read_csv('user_demographics.csv')
demographics_data.head(n=2)
uid reg_date device gender country age
0 5.277e+07 2018-03-07T00:00:00Z and F FRA 27
1 8.434e+07 2017-09-22T00:00:00Z iOS F TUR 22
paywall_views = pd.read_csv('paywall_views.csv')
paywall_views.head(n=2)
uid date purchase sku price
0 32209877 2016-12-04 14:20:49+00:00 0 NaN NaN
1 32209877 2016-12-05 22:17:12+00:00 0 NaN NaN
# Join our paywall views to the user demographics purchase_data = demographics_data.merge( paywall_views, how='left', on=['uid'])
# Find the total purchases for each user total_purchases = purchase_data.groupby( by=['uid'], as_index=False).purchase.sum()
# Find the mean number of purchases per user total_purchases.purchase.mean()
3.15
# Find the minimum number of purchases made by a user
# over the period
total_purchases.purchase.min()
0.0
# Find the maximum number of purchases made by a user
# over the period
total_purchases.purchase.max()
17.0
User-days: User interactions on a given day
# Group our data by users and days, then find the total purchases total_purchases = purchase_data.groupby( by=['uid', 'date'], as_index=False)).purchase.sum()
# Calcualte summary statistics across user-days total_purchases.purchase.mean() total_purchases.purchase.min() total_purchases.purchase.max()
0.0346
0.0
3.0
Customer Analytics and A/B Testing in Python