How to groupby on a index column in pyspark pandas?

140 Views Asked by At

I have a pandas API for spark (Koala) dataframe as below,

         c1   c2
id name
a1 a     1    1
a1 b     2    2
b1 c     3    3

How can I do groupby like below,

df.groupby(level=1).sum()
1

There are 1 best solutions below

0
G.G On

reset the level first:

df.reset_index(level=1).groupby('name').sum()