lets say I have this dataframe:
data = {"col1":["yes", "no", "yes", "no", "yes", "no", "yes", "no"],\
"col2":["A", "A", "B", "B", "C", "C", "D", "D"],\
"col3":[24, 20, 19, 17, 24, 27, 22, 18]}
df = pd.DataFrame(data=data)
Now, If I want to t test the col3 values between col1 yes and no, I can using the following function:
pg.ttest(*df.groupby("col1")["col3"].apply(lambda x:x.values))
But, lets say I wand to compare based on groupby both col1 and col2, e.g. comparing "A" "yes" vs "A" "no", "B" "yes" vs "B" "no" etc. I know I can groupby 2 groups, but every code I tried to fit the groupby 2 groups to t test had failed.