Customer Analytics and A/B Testing in Python
Ryan Grossman
Data Scientist, EDO

import pandas as pd# load customer_demographics customer_demographics = pd.read_csv('customer_demographics.csv')# print the head of customer_demographics print(customer_demographics.head())
uid reg_date device gender country age
54030035 2017-06-29 and M USA 19
72574201 2018-03-05 iOS F TUR 22
64187558 2016-02-07 iOS M USA 16
92513925 2017-05-25 and M BRA 41
99231338 2017-03-26 iOS M FRA 59
# load customer_subscriptions customer_subscriptions = pd.read_csv('customer_subscriptions.csv')# print the head of customer_subscriptions print(customer_subscriptions.head())
uid lapse_date subscription_date price
59435065 2017-07-06 2017-07-08 499
26485969 2018-03-12 None 0
64187658 2016-02-14 2016-02-14 499
99231339 2017-04-02 None 0
64229717 2017-05-24 2017-05-25 499
Choosing a KPI
JOINpandas:pd.merge(df1, df2)df1.merge(df2)
# merge customer_demographics (left) and customer_subscriptions (right) sub_data_demo = customer_demographics.merge(# right dataframe customer_subscriptions,# join type how='inner',# columns to match on=['uid'])sub_data_demo.head()
uid reg_date device ...price
54030729 2017-06-29 and ...499

Customer Analytics and A/B Testing in Python