I have a dataframe that looks roughly like:
2020-01-01 2020-01-02 2020-01-03 2020-01-05
00:00:00 11 47 54 10
01:00:00 12 49 46 22
...
23:00:00 15 34 22 40
Expected output...
2020-01-01 00:00:00 11
2020-01-01 01:00:00 12
...
2020-01-01 23:00:00 12
2020-01-02 00:00:00 47
2020-01-02 01:00:00 49
...
2020-01-01 23:00:00 34
...
Use
DataFrame.melt
with convert index to column, then convert columns to datetimes and timedeltas and join together withDataFrame.pop
for extract columns:If
pop
is not used is necessary remove columns byDataFrame.drop
:Another idea with
DataFrame.unstack
and joinMultiIndex
withmap
and convert toDatetimeIndex
, output isSeries
: