I have a dataframe like this:
DURATION CLUSTER COEFF
3 0 0.34
3 1 -0.005
3 2 1
3 3 0.33
4 0 -0.02
4 1 -0.28
4 2 0.22
4 3 0.48
5 0 0.65
5 1 -0.26
5 2 0.1
5 3 0.15
I want to create a RESULT categorical column according to the "COEFF" coefficients for each "DURATION". The one with the greatest "COEFF" value will be "First" and so on.
Desired output like this:
DURATION CLUSTER COEFF RESULT
3 0 0.34 Second
3 1 -0.005 Fourth
3 2 1 First
3 3 0.33 Third
4 0 -0.02 Third
4 1 -0.28 Fourth
4 2 0.22 Second
4 3 0.48 First
5 0 0.65 First
5 1 -0.26 Fourth
5 2 0.1 Third
5 3 0.15 Second
Could you please help me about this?