I'm trying to apply a z-test to every row of a pandas dataframe like so:
from statsmodels.stats.proportion import proportions_ztest
def apply_ztest(n1, n2, x1, x2):
return proportions_ztest(
count=[n1 , n2],
nobs=[x1, x2],
alternative='larger'
)[1]
df['p_val'] = df.apply(lambda x: apply_ztest(df['n1'], df['n2'], df['obs1'], df['obs2']))
But I'm getting this error raised:
NotImplementedError: more than two samples are not implemented yet
I feel like either there's a different way to do this or I'm messing something up. Can anyone tell me how to do/fix this?