I have a pandas dataframe in Python.
datetime machineID
0 2021-10-01 00:00:00 1.0
1 2021-10-01 00:00:00 2.0
2 2021-10-01 00:00:00 3.0
3 2021-10-01 00:00:00 4.0
4 2021-10-01 00:00:00 5.0
... ... ...
443 2021-10-07 12:00:00 28.0
444 2021-10-07 12:00:00 29.0
445 2021-10-07 12:00:00 30.0
446 2021-10-07 12:00:00 31.0
447 2021-10-07 12:00:00 32.0
There are 7 days in this dataframe from 2021-10-01 to 2021-10-07. This is indexed as per datetime like for every machineID, all the machineIDs come for that date then for next date all machineIDs come and so on.
What I want is, I want to reindex this dataframe such that for each machineID, all 7 dates come then for next machineID all dates come. Something like this,
datetime machineID
0 2021-10-01 00:00:00 1.0
1 2021-10-02 00:00:00 1.0
2 2021-10-03 00:00:00 1.0
3 2021-10-04 00:00:00 1.0
4 2021-10-05 00:00:00 1.0
... ... ...
443 2021-10-03 12:00:00 32.0
444 2021-10-04 12:00:00 32.0
445 2021-10-05 12:00:00 32.0
446 2021-10-06 12:00:00 32.0
447 2021-10-07 12:00:00 32.0
I am not able to find any method to do so.