我有一个看起来像这样的 pandas 数据框。它是一个频率表。
登陆页面 | 0 | 1 |
---|---|---|
新页面 | 128045 | 17264 |
旧页 | 127785 | 17489 |
其中 0 = 未转换,1 = 已转换。
我正在尝试计算两个样本的 Z 测试,以显示新页面是否会影响转化率。
我是Python新手,我不知道如何使用这个数据框进行测试。
非常感谢任何帮助。
非常感谢。
proportions_ztest
:
from statsmodels.stats.proportion import proportions_ztest
tmp = df.set_index(['landing_page']).loc[['old_page', 'new_page']]
stat, p_value = proportions_ztest(count=tmp[1], nobs=tmp[[0, 1]].sum(axis=1),
alternative='two-sided')
输出:
1.3102408579271012 0.19011436776805024