My DataFrame looks like this:
00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00
Code Alias Date
RO FI 05.07.2010 53.97 52.11 52.11 52.11 52.11 52.11 51.85 51.55
JY 05.07.2010 53.97 52.11 52.11 52.11 52.11 52.11 51.85 65.85
SE 05.07.2010 53.97 52.11 52.11 52.11 52.11 52.11 51.85 51.55
SJ 05.07.2010 53.97 52.11 52.11 52.11 51.49 52.11 51.85 51.55
When using df.stack(), i get the columns (hours) as a seperate index. How do I merge the 'Date' index and the new 'hours' index to form a DateTime index?
Like this:
Value
Code Alias Date
RO FI 05.07.2010 00:00 53.97
05.07.2010 01:00 52.11
05.07.2010 02:00 52.11
etc
It's not pretty, but it'll do
strftime
to turnDate
into a string and concatenate withHour
pd.to_datetime