So I've essentially got this dataframe:
,club_name,tr_begin,year,ranking
0,ADO Den Haag,1357,2010,6.0
1,ADO Den Haag,1480,2011,15.0
2,ADO Den Haag,1397,2012,9.0
3,ADO Den Haag,1384,2013,9.0
4,ADO Den Haag,1451,2014,13.0
What I want to do is this, I want to go through every ranking and put them into a class based on it's value. So a ranking of 6 would go into class number 2 and a ranking 1 would go into class number 1. The conversion table is this:
if ranking > 0 and ranking =< 3:
rank_class = 1
if ranking > 3 and ranking =< 6:
rank_class = 2
etc etc etc
This I would like to happen in multiples of 3 up until 18.
So my hoped output would be:
,club_name,tr_begin,year,ranking, ranking_class
0,ADO Den Haag,1357,2010,6.0, 2
1,ADO Den Haag,1480,2011,15.0, 5
2,ADO Den Haag,1397,2012,9.0, 3
3,ADO Den Haag,1384,2013,9.0, 3
4,ADO Den Haag,1451,2014,13.0, 5
I tried with the mask function, and by making a new dataframe and then merging, This worked but just seemed very sloppy. Is there some easy way to do this?
Thanks in advance