I have a dataframe like this
date
2018-02-28 09:00:00 78700.0
2018-02-28 10:00:00 78900.0
2018-02-28 11:00:00 78100.0
2018-02-28 12:00:00 78100.0
2018-02-28 13:00:00 77500.0
...
2018-11-30 11:00:00 70000.0
2018-11-30 12:00:00 69800.0
2018-11-30 13:00:00 69800.0
2018-11-30 14:00:00 69600.0
2018-11-30 15:00:00 69400.0
and I want to pivot a time series variable for a certain length in each row (this case, timestep is 6, so I expect 6 columns per row). The expected result below is similar to a subset of a Toeplitz matrix.
date 0 1 2 3 4 5
2018-02-28 09:00:00 78700.0 78900.0 78100.0 78100.0 77500.0 77100.0
2018-02-28 10:00:00 78900.0 78100.0 78100.0 77500.0 77100.0 77100.0
2018-02-28 11:00:00 78100.0 78100.0 77500.0 77100.0 77100.0 76300.0
2018-02-28 12:00:00 78100.0 77500.0 77100.0 77100.0 76300.0 76200.0
2018-02-28 13:00:00 77500.0 77100.0 77100.0 76300.0 76200.0 76700.0
... ... ... ... ... ... ...
2018-11-29 12:00:00 72000.0 72000.0 71800.0 71500.0 71500.0 70000.0
2018-11-29 13:00:00 72000.0 71800.0 71500.0 71500.0 70000.0 70000.0
2018-11-29 14:00:00 71800.0 71500.0 71500.0 70000.0 70000.0 69800.0
2018-11-29 15:00:00 71500.0 71500.0 70000.0 70000.0 69800.0 69800.0
2018-11-30 09:00:00 71500.0 70000.0 70000.0 69800.0 69800.0 69600.0
I just appended splited chunks into new Dataframe to make this, but it's too slow ;( Is there a elegant way to perform this transformation?