I have data like this (it's a time series problem):
Time y
2017-01-01 00:00:00 34002
2017-01-01 01:00:00 37947
2017-01-01 02:00:00 41517
2017-01-01 03:00:00 44476
2017-01-01 04:00:00 46234
I want to extract the hour, day of the week and day off as categorical variables, but somehow it doesn't work:
data = pd.DataFrame(dataset)
data.columns = ["y"]
data.index = pd.to_datetime(data)
data["hour"] = data.index.hour
data["weekday"] = data.index.weekday
data['is_weekend'] = data.weekday.isin([5,6])*1
data.head()
Python throws the following error, with which I don't know what to do:
2 data.columns = ["y"]
3
----> 4 data.index = pd.to_datetime(data)
5 data["hour"] = data.index.hour
6 data["weekday"] = data.index.weekday
ValueError: to assemble mappings requires at least that [year, month, day] be specified: [day,month,year] is missing