I have a dataframe
df =
type value
A 5
A 7
B 2
B 6
A 1
I was to apply function per the groups of the column type , so the rank will apply per type and the new df will be
df =
type value rank
A 5 1
A 7 0
B 2 1
B 6 0
A 1 2