I am trying to add arbitrarily generated hours to a date time index. My solution seems to work in my regular Jupyter notebook running python 3.7, but doesn't work at all in the Quantopian research environment.
I add the hours to my date time using
hp['game_date'] = pd.to_datetime(hp['Date'], dayfirst=True,errors="coerce")
hp["game_date"]+=pd.to_timedelta(hp.Hour,unit="h")
It appears that the hours have been added at first, the output looks like this when using iloc[] to check the if the hours were added.
2020-01-24 00:00:00.000000004
But when I convert game_date to an index, like this
hp=hp.set_index(["game_date","Player"])
The hours seem to disappear, giving me this. Giving me duplicated indexes which I'm trying to avoid.
2020-01-24 00:00:00
For context, I'm using Quantopian for daily fantasy sports.