I have a pandas dataframe with a DatetimeIndex, e.g.
In: ts = pd.date_range('2013-01-01 00:00', periods=17520, freq='30min')
In: values = list(range(1, 17520))
In: df = pd.DataFrame(values, index=ts)
I want to reshape the dataframe so it has dates as the index and hours [0,0.5,1.0,1.5,.....] as the columns.
I have this:
df.pivot(index=df.index.date, columns=df.index.time, values='values')
but it gives me a key error with a list of dates not in index