Created
August 23, 2019 12:56
-
-
Save karamanbk/ddf0a83d1ea9d6ce9ba8ff784e727c93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#create hv segment | |
df_hv = pd.DataFrame() | |
df_hv['customer_id'] = np.array([count for count in range(20000)]) | |
df_hv['segment'] = np.array(['high-value' for _ in range(20000)]) | |
df_hv['group'] = 'control' | |
df_hv.loc[df_hv.index<10000,'group'] = 'test' | |
df_hv.loc[df_hv.group == 'control', 'purchase_count'] = np.random.poisson(0.6, 10000) | |
df_hv.loc[df_hv.group == 'test', 'purchase_count'] = np.random.poisson(0.8, 10000) | |
df_lv = pd.DataFrame() | |
df_lv['customer_id'] = np.array([count for count in range(20000,100000)]) | |
df_lv['segment'] = np.array(['low-value' for _ in range(80000)]) | |
df_lv['group'] = 'control' | |
df_lv.loc[df_lv.index<40000,'group'] = 'test' | |
df_lv.loc[df_lv.group == 'control', 'purchase_count'] = np.random.poisson(0.2, 40000) | |
df_lv.loc[df_lv.group == 'test', 'purchase_count'] = np.random.poisson(0.3, 40000) | |
df_customers = pd.concat([df_hv,df_lv],axis=0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment