Customer Analytics and A/B Testing in Python
Ryan Grossman
Data Scientist, EDO
Paywall Text: Test & Control
Questions
# Join our demographics and purchase data purchase_data = demographics_data.merge( paywall_views,how='left', on=['uid'])
# Find the total revenue per user over the period total_revenue = purchase_data.groupby(by=['uid'], as_index=False).price.sum()
total_revenue.price = np.where( np.isnan(total_revenue.price), 0, total_revenue.price)
# Calculate the average revenue per user avg_revenue = total_revenue.price.mean() print(avg_revenue)
16.161
avg_revenue * 1.01 # 1% lift in revenue per user
16.322839545454478
# Most reasonable option
avg_revenue * 1.1 # 10% lift in revenue per user
17.77
avg_revenue * 1.2 # 20% lift in revenue per user
19.393
DataFrame.std()
: Calculate the standard deviation of a pandas DataFrame# Calculate the standard deviation of revenue per user
revenue_variation = total_revenue.price.std()
print(revenue_variation)
17.520
# Calculate the standard deviation of revenue per user
revenue_variation = total_revenue.price.std()
17.520
revenue_variation / avg_revenue
1.084
# Find the average number of purchases per user
avg_purchases = total_purchases.purchase.mean()
3.15
# Find the variance in the number of purchases per user
purchase_variation = total_purchases.purchase.std()
2.68
purchase_variation / avg_purchases
0.850
# Aggregate our data sets purchase_data = demographics_data.merge( paywall_views, how='inner', on=['uid'] )
# conversion rate = total purchases / total paywall views conversion_rate = (sum(purchase_data.purchase) / purchase_data.purchase.count()) print(conversion_rate)
0.347
Customer Analytics and A/B Testing in Python