I have a dataframe, I want to groupby Col1 Col2 Col3 and get the 0 frequency of Value column: df =
Col1 Col2 Col3 Value
Val1 Val2 A 0
Val1 Val2 A 1
Val1 Val2 A 2
Val1 Val2 A 0
Val1 Val2 A 1
Val1 Val2 B 0
Val1 Val2 B 0
Val1 Val2 B 0
Val1 Val2 B 0
Val1 Val2 B 1
...
How do I apply groupby to achieve
Col1 Col2 Col3 Fercentage_of_0
Val1 Val2 A 0.2
Val1 Val2 B 0.8
...
Thank you!
df['Value'].eq(0).groupby([df['Col1'],df['Col2'],df['Col3']]).mean()
? – Quang Hoang