I have recently faced a similar problem (answered here) whereby conversion of a date to a pandas DatetimeIndex and subsequent groupby
using those dates led to an error where the date appeared as 1970-01-01 00:00:00+00:00
.
I'm facing this problem in a different context now, and the previous solution isn't helping me.
I have a frame like this
import pandas as pd
from dateutil import tz
data = { 'Events' : range(1, 5 + 1 ,1), 'ID' : [1, 1, 1, 1, 1]}
idx = pd.date_range(start='2008-01-01', end='2008-01-05', freq='D', tz=tz.tzlocal())
frame = pd.DataFrame(data, index=idx)
Events ID
2008-01-01 00:00:00+00:00 1 1
2008-01-02 00:00:00+00:00 2 1
2008-01-03 00:00:00+00:00 3 1
2008-01-04 00:00:00+00:00 4 1
2008-01-05 00:00:00+00:00 5 1
and I want to change the index from just the date, to a MultiIndex of [date, ID]
, but in doing so that "1970 bug" appears
frame.set_index([frame.ID, frame.index])
Events ID
ID
1 2008-01-01 00:00:00+00:00 1 1
1970-01-01 00:00:00+00:00 2 1
1970-01-01 00:00:00+00:00 3 1
1970-01-01 00:00:00+00:00 4 1
1970-01-01 00:00:00+00:00 5 1
Versions
- Python 2.7.11
- Pandas 0.18.0