I am attempting to build 3 separate columns in my dataframe for the value of the time stamp HOUR, DAY, MONTH with the DatetimeIndex.
I appologize for data that cant be reproduced because my data set is being read from a CSV File.
boilerDf = pd.read_csv('C:\\Users\\Python Scripts\\Deltadata.csv', index_col='Date', parse_dates=True)
print(boilerDf.info())
This returns:
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 23797 entries, 2017-10-25 05:00:08.436000 to 2018-01-02 05:45:14.419000
Data columns (total 3 columns):
hwr 23797 non-null float64
hws 23797 non-null float64
oat 23797 non-null float64
dtypes: float64(3)
memory usage: 743.7 KB
None
I can see on the pandas.pydata.org website their is 3 methods for what I am trying to do except I want to create separate dataframe (columns):
DatetimeIndex.month
DatetimeIndex.day
DatetimeIndex.hour
This code below does not work on adding a seperate dataframe column for the hour of the date time index... Any ideas?
boilerDf['Hour'] = boilerDf.DatetimeIndex.hour
Kind regards
I also have the data uploaded here on Github: bbartling/Data on Github