I have one dataframe df:
route value
1 1 1
2 2 2
3 2 2
4 2 1
5 1 2
The column value gives success (2) or fail (1), I want to create a third column which gives the succes rate for each route.
Desired Output:
route value Rate
1 1 1 0.5
2 2 2 0.66
3 2 2 0.66
4 2 1 0.66
5 1 2 0.5
Thank you for your help