I have a Pandas Series of hourly data for a whole year, where the index is the DatetimeIndex, and a column with one value for each hour in the year.
I want to create a Dataframe so that each row represents the day in the year (1-365) and each column represents the hour in the day (0-23). The shape of the DataFrame should therefore have 365 rows and 24 columns.
I was hoping that this would work, but somehow the values do not get filled in:
df = pd.DataFrame(prices,index=prices.index.dayofyear.unique(),columns=prices.index.hour.unique())
Example of Series for first two days:
I also didn't manage to make it work with this:
df = pd.pivot(data=prices,index=prices.index.dayofyear.unique(),columns=prices.index.hour.unique())
Thanks in advance!