I have following dataframe:
Index ColA ColB ColC ColD
0 1 4 13 ABC
1 12 1 24 ABC
2 36 18 1 ABC
3 41 45 1 ABC
Now I'm searching for a simple command to transform the pandas df in such a way that the values of ColA, ColB, and ColC are resembled as follows:
for each row:
if value in ColA <= 12 then 1
if value in ColA > 12 and <= 24 then 2
if value in ColA > 24 and <= 36 then 3
if value in ColA > 36 then 4
(the same also for the other columns)
So the result would look like this:
Index ColA ColB ColC ColD
0 1 1 2 ABC
1 1 1 2 ABC
2 3 2 1 ABC
3 4 4 1 ABC
Is there a simple way to achieve this? :-)
Best regards, André