image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

sns.set_style('white')
plt.rc('axes', titlesize=13)
plt.rc('axes', labelsize=12)
plt.rc('xtick', labelsize=11)
plt.rc('ytick', labelsize=11)
plt.rc('legend', fontsize=11)
plt.rc('font', size=10)

path = '../input/mobile-games-ab-testing/cookie_cats.csv'
df = pd.read_csv(path)

df.shape

df.userid = df.userid.astype(str)

df.userid.dtypes

df.version.unique()

diffs_1 = []
for i in range(10000):
    boot_sample = df.sample(df.shape[0], replace=True)
    gate30_df_1 = boot_sample.query('version == "gate_30"')['retention_1'].mean()
    gate40_df_1 = boot_sample.query('version == "gate_40"')['retention_1'].mean()
    diffs_1.append(gate40_df_1 - gate30_df_1)

plt.figure(figsize=(16, 5), tight_layout=True)
ax = sns.histplot(diffs_1, kde=True, kde_kws={'bw_method': 0.4})
ax.lines[0].set_color('black')
plt.ylim(0, 600)
plt.title("Sampling Distribution for difference between control group's Day 1 Retention and treatment group's Day 1 Retention")
plt.ylabel('Frequency')
plt.xlabel('Difference')