My df looks like this:
value type
12 x
34 z
54 x
14 y
I want to create a new column df.sum where I want to do a sum of the value col but only where the type == x. The remaining rows should be empty. So for example, the output should be like this:
value type sum
12 x 86
34 z
54 x 86
14 y