I have a dataframe zdf that looks like the following:
Index A B C Mean
2008-11-21 23 12 16 18
2008-11-24 26 14 15 17
2008-11-25 28 20 21 25
2008-11-26 25 26 27 26
stats.ttest_1samp
from scipy.stats import stats
for i in range(zdf.shape[0]+1):
zdf.ix[i,'ttest'] = stats.ttest_1samp(list(zdf.iloc[i,:-1]),zdf.iloc[i,-1])
you can't set an array element with a sequence with .ix[]
so you need to pass a single array such has:
for i in range(zdf.shape[0]+1):
zdf.ix[i,'ttest_res1'] = stats.ttest_1samp(zdf.iloc[i,:-1].values,zdf.iloc[i,-1])[1]
zdf.ix[i,'ttest_res2'] = stats.ttest_1samp(zdf.iloc[i,:-1].values,zdf.iloc[i,-1])[2]
also, I would pass an array instead of a list in the first argument with .values