Alexis G Alexis G - 1 year ago 71
Python Question

Sampling a datetime from lines for days and columns for hours

I have a matrix where lines represent days and columns represent hours. I am looking for resampling this data to have a datetime as index.

DATES; H0;H1;H2;H3;...

When I use the df.resample('H') function I get the following results. I want now match the columns value with the hours of each day to fill the values.

2013-01-01 00:00:00 1.35882
2013-01-01 01:00:00 NaN
2013-01-01 02:00:00 NaN
2013-01-01 03:00:00 NaN
2013-01-01 04:00:00 NaN

Does anyone please have an idea on how to proceed?

Thanks Alexis

Answer Source

Assuming DATES is your index, this should work


If 'DATES' is not your index, you can set it this way


Note: This will not set time format to what is in your example

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download