May-07-2022, 08:19 AM
Ji,
I have below df, and I want to group by coulmn2,column3 and calculate mean of other columns and unique count.
I have below df, and I want to group by coulmn2,column3 and calculate mean of other columns and unique count.
df: col1 col2 col3 col4 col5 A1 A x1 3 1 A2 A x1 2 3 A3 A x1 4 2 B2 P x2 3 2 B2 P x2 1 4 C6 Y q2 1 4 [python]out: col2 col3 col4 col5 count A x1 3 2 3 P x2 2 3 2 Y q2 1 4 1I use below code but it does not give count
df.groupby(['col2','col3']).mean().reset_index()But I am getting count.