I have the dataframe
C1 c10 val val_type
1 3 5 target
1 3 8 end
1 3 9 other
2 8 1 end
2 8 2 target
2 8 9 other
The values of C1, C10 creates groups of 3. Within these groups I want to create a new column that is target/end. So the output will be:
C1 c10 val val_type new
1 3 5 target 0.652
1 3 8 end 0.652
1 3 9 other 0.652
2 8 12 end 0.166
2 8 2 target 0.166
2 8 9 other 0.166
What is the best way to do so?
edit: Ignore other