I have a dataframe with two columns a and b, I want a column c in the output dataframe whose values are the sum of values in the column b corresponding to 1's in the column a and store that sum one index below in the c column
This is the input data that I have :
a b
0 0 0.1
1 0 0.4
2 0 0.2
3 1 0.4
4 1 0.8
5 0 0.1
6 0 1.3
7 1 2.4
8 1 1.2
9 1 1.7
10 1 0.9
11 0 3.2
and I want the output to be something like this:
a b c
0 0 0.1 0.0
1 0 0.4 0.0
2 0 0.2 0.0
3 1 0.4 0.0
4 1 0.8 0.0
5 0 0.1 1.2
6 0 1.3 0.0
7 1 2.4 0.0
8 1 1.2 0.0
9 1 1.7 0.0
10 1 0.9 0.0
11 0 3.2 6.2
This is my first question, i'm sorry if my question is not aesthetic enough,any help would be appreciated,Thanks in advance