Mar-30-2017, 08:17 PM
You should check documentation forĀ pandas dataframe. columns parameter accepts list of column names, so you are trying to create dataframe with colums named as values in df.Hour column (with width given by lenght of your original dataframe).
If you just want to use existing column as an index, just use:
If you just want to use existing column as an index, just use:
df2 = df.set_index('Day of Week', drop=True)[['Hour']]that will set index values from Day of Week column and deletes Day of Week column. If your original dataframe contains only Hour and Day of Week columns, selecting with
[['Hour']]
is obsolete.