Closed
Description
In the case below, setting utc=True
in pandas.to_datetime actually removes the UTC attribute from the input:
import pandas as pd
import pytz
start = pd.Timestamp('2014-01-01', tz=pytz.UTC)
end = pd.Timestamp('2014-01-03', tz=pytz.UTC)
date_range = pd.bdate_range(start, end)
df = pd.DataFrame({'x':1}, index=date_range)
df.index
# DatetimeIndex([...], dtype='datetime64[ns, UTC]', freq='B')
pd.to_datetime(df.index, utc=True)
# DatetimeIndex([...], dtype='datetime64[ns]', freq='B')
the last function removes the UTC attribute from the input, even though utc
is set to True
.
This only happens in pandas 0.17.1. pandas 0.16.x have a different implementation and does not have this issue.