I have the following table as input:
| x | y | |
|---|---|---|
| 0 | -0.872803 | 137.097977 |
| 1 | -0.418766 | 821.549805 |
| 2 | -0.657833 | 712.427856 |
| 3 | -0.922091 | 126.871956 |
| 4 | -0.847130 | 217.126068 |
| 5 | 0.692070 | 2166.090820 |
| 6 | -0.858773 | 297.893188 |
| 7 | -0.466285 | 634.510315 |
| 8 | -0.774720 | 91.447876 |
| 9 | -0.111050 | 1200.390625 |
| 10 | 0.325138 | 1759.597900 |
And I need to generate something like this:
| x | y | pos_when_sorted_by_x | pos_when_sorted_by_y | |
|---|---|---|---|---|
| 0 | -0.872803 | 137.097977 | 9 | 8 |
| 1 | -0.418766 | 821.549805 | 3 | 3 |
| 2 | -0.657833 | 712.427856 | 5 | 4 |
| 3 | -0.922091 | 126.871956 | 10 | 9 |
| 4 | -0.847130 | 217.126068 | 7 | 7 |
| 5 | 0.692070 | 2166.090820 | 0 | 0 |
| 6 | -0.858773 | 297.893188 | 8 | 6 |
| 7 | -0.466285 | 634.510315 | 4 | 5 |
| 8 | -0.774720 | 91.447876 | 6 | 10 |
| 9 | -0.111050 | 1200.390625 | 2 | 2 |
| 10 | 0.325138 | 1759.597900 | 1 | 1 |
pos_when_sorted_by_x and pos_when_sorted_by_y are based on the location in the sorted dataframe by each of these columns.