My df looks like this:
cat1 cat2 x1 x2 x3 x4 x5 x6 . . .
0 str str float float float float float float . . .
1 str str float float float float float float . . .
. . . . . . . . . . . .
. . . . . . . . . . . .
I tried this:
df = df.groupby(['cat1','cat2']).apply(pd.expanding_mean)
but it gives me
ValueError: could not convert string to float:
The only lines are in the group. This works great, but I don't need:
df = df.groupby(['cat1','cat2']).mean()
source
share