Reputation: 1289
I have 2 data frames pd and pd2:
pd
Name A B Mean
t1 1.0 2.0 1.5
t2 2.0 3.0 2.5
t3 9.4 3.3 6.35
pd2
Name A B Mean
t1 1.1 2.7 1.9
t2 3.7 3.0 3.35
t3 10.4 4.3 7.35
I would like to do the ttest calculation for columns 'A' on both dataframes and column B on both dataframes the result can be added to one of the dataframes or it can be added to a new data frame. The output should have the columns:
ttestA ttestB ttestC ...etc
Upvotes: 0
Views: 3262
Reputation: 323366
Using for loop
from scipy import stats
l=[]
listofname=['A','B']
for x in listofname:
l.append(stats.ttest_ind(df[x],df2[x], equal_var=False))
Upvotes: 1