I have a dataframe df
as
Decile 2_Con 3_Con 6_Con Pred
1 0 0 0 0
1 0 0 1 1
1 0 0 1 1
2 0 0 0 0
2 0 1 0 1
2 0 1 1 1
Objective:
I want to compute the count of 6_Con, 3_Con and 2_Con when I filter the above df
by Pred and set 6_Con ,3_con and 2_Con to 1 for each Decile.
So the resultant Dataframe should look like:
Decile 2_Con 3_Con 6_Con Pred
1 0 0 2 2 <--We are only counting 1 in the columns for each Decile
2 0 2 1 2
How to achieve this? I am not able to generate a plausible code here.
Thanks in advance