I have dataframe df, containing patient data, as shown below:
| patient_id | x | y | path | target |
|------------ |----- |----- |------ |-------- |
| 4423 | 234 | 53 | .... | 1 |
| 4423 | 259 | 68 | .... | 0 |
| ... | ... | ... | ... | ... |
| 3351 | 100 | 34 | .... | 1 |
| 3351 | 150 | 78 | .... | 1 |
What I would like to do is shuffle the data while maintaining the patient_id order. In other words, I want to df.groupby('patient_id')
and then shuffle my data.
Is there a way to achieve this using pandas or sklearn?