You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When timezone-aware datetime.datetime objects are used as the index of a DataFrame via set_index(), undoing the operation with reset_index() loses the timezone.
After the round-trip, the datetime.datetime column becomes a datetime64[ns] column, which can be considered a feature, not a bug. The times are correctly converted to UTC (which is good if you're going to lose the timezone), but the loss of timezone information seems like a bug.
This has been tested against version 0.9.1 on Python 2.7 (Windows 32-bit)
Code to recreate
import datetime, dateutil, pandas as pd
tzoffset = dateutil.tz.tzoffset(None, -5*60*60)
ts = datetime.datetime(2012,11,15,10,38,4,tzinfo=tzoffset)
print ts # this has a timezone
df = pd.DataFrame([[ts, 15]], columns=['ts', 'val'])
dfi = df.set_index('ts')
print dfi.index # this has a timezone
df2 = dfi.reset_index() # <-- This is where the timezone gets lost
print df2['ts'][0] # this doesn't have a timezone
print df2['ts'][0].to_datetime() # neither does this
The text was updated successfully, but these errors were encountered:
When timezone-aware datetime.datetime objects are used as the index of a DataFrame via set_index(), undoing the operation with reset_index() loses the timezone.
After the round-trip, the datetime.datetime column becomes a datetime64[ns] column, which can be considered a feature, not a bug. The times are correctly converted to UTC (which is good if you're going to lose the timezone), but the loss of timezone information seems like a bug.
This has been tested against version 0.9.1 on Python 2.7 (Windows 32-bit)
Code to recreate
The text was updated successfully, but these errors were encountered: