I have a pandas dataframe that looks like
columnA columnB
3 -1
73 2
2 13
-2 24
4 1
8 2
23 3
13 5
2 2
0 3
1 4
2 1
7 2
2 1
2 2
5 3
For columnA that range is 73-(-2)=75 and hence the four quartiles are given by 1st quartile = [-2 – 16.75], 2nd quartile = [16.75, 35.5], 3rd quartile = [35.5, 54.25], 4th quartile = [54.25, 73] and I want to transform the columns by labelling which quartile the element is in. So for example, columnA would become
columnA columnB
1 -1
4 2
1 13
1 24
1 1
1 2
2 3
1 5
1 2
1 3
1 4
1 1
1 2
1 1
1 2
1 3
I think it has something to do with .transform
but I am not how how to partition it into quartiles.