I have a pandas dataframe which I want to shuffle, but keep the order of 1 column.
So imagine I have the following df:
| i | val | val2| ID |
| 0 | 2 | 2 |a |
| 1 | 3 | 3 |b |
| 2 | 4 | 4 |a |
| 3 | 6 | 5 |b |
| 4 | 5 | 6 |b |
I want to shuffle the rows but keep the order of the ID column of the first df. My wanted result would be something like this:
| i | val | val2| ID |
| 2 | 4 | 4 |a |
| 4 | 5 | 6 |b |
| 0 | 2 | 2 |a |
| 3 | 6 | 5 |b |
| 1 | 3 | 3 |b |
How do I do this?