text_plain_output_1.png
from statsmodels.stats import proportion

import numpy as np

import pandas as pd

SHEET_ID = '10DM_ZqwV6CvOryD6u3pYHb5scjEfiwfkitUGTCG8l7Y'
SHEET_NAME = 'AAPL'
url = f'https://docs.google.com/spreadsheets/d/{SHEET_ID}/gviz/tq?tqx=out:csv&sheet={SHEET_NAME}'
df = pd.read_csv(url, decimal=',')

df_retention_ab = df.groupby('version').agg({'userid': 'count', 'retention_1': 'mean', 'retention_7': 'mean', 'sum_gamerounds': 'sum'})
df_retention_ab

df_c = df[df['version'] == 'gate_30']
df_t = df[df['version'] == 'gate_40']

#calc of difference of retentionin between 2 groups
ret1_dif = (df_c.describe(include='all').loc['mean']['retention_1'] - df_t.describe(include='all').loc['mean']['retention_1']) / df_t.describe(include='all').loc['mean']['retention_1']
ret7_dif = (df_c.describe(include='all').loc['mean']['retention_7'] - df_t.describe(include='all').loc['mean']['retention_7']) / df_t.describe(include='all').loc['mean']['retention_7']
ret1_dif, ret7_dif

k1 = df_t['retention_1'].sum()
k2 = df_c['retention_1'].sum()
(k1, k2)

n1 = df_t.shape[0]
n2 = df_c.shape[0]
(n1, n2)

z_score, z_pvalue = proportion.proportions_ztest(np.array([k1, k2]), np.array([n1, n2]))

chisq, pvalue, table = proportion.proportions_chisquare(np.array([k1, k2]), np.array([n1, n2]))

k1 = df_t['retention_7'].sum()
k2 = df_c['retention_7'].sum()
(k1, k2)

n1 = df_t.shape[0]
n2 = df_c.shape[0]
(n1, n2)

z_score, z_pvalue = proportion.proportions_ztest(np.array([k1, k2]), np.array([n1, n2]))
print('Results are ', 'z_score =%.3f, pvalue = %.3f' % (z_score, z_pvalue))