BUG: Timestamp.tz_localize resets nanosecond by sinhrks · Pull Request #7534 · pandas-dev/pandas (original) (raw)

Timestamp.tz_localize resets nanosecond.

t = pd.Timestamp('2011-01-01') + pd.offsets.Nano(1)
t.tz_localize('US/Eastern')
# Warning: discarding nonzero nanoseconds
#2011-01-01 00:00:00-05:00

Even though DatetimeIndex.tz_convert can preserve it.

idx = pd.date_range('3/11/2012 04:00', periods=10, freq='N')
idx.tz_localize('US/Eastern')
# <class 'pandas.tseries.index.DatetimeIndex'>
# [2012-03-11 04:00:00-04:00, ..., 2012-03-11 04:00:00.000000009-04:00]
# Length: 10, Freq: N, Timezone: US/Eastern