I regularly face an issue when I have an excel file which looks like the following:
Date , Hour
2015-12-15 , 1
(Please note that this data are read from excel so the date is in excel whatever format)
Now I tried:
df2=pd.read_excel(name, sheetname=0,skiprows=17, parse_dates="Date")
df2["test"]=df2.apply(lambda val: val["Date"]+timedelta(hours=int(df2["Hour"])-1))
However, here I get the error:
KeyError: 'Date', ' occured at index Date'
My df2 have the following types:
Date: datetime64
Hour: object
In addition I tried:
df2.set_index(df2["Date"]+df2["Hour"])
but without success.
Does anybody has a clue how to avoid this error, or how to get an index column in the following format:
2015-12-15 00:00:00