Closed
Description
Apply tz_convert_single
to the same time representation with different tz should be all True
?
import pandas as pd
import numpy as np
import datetime
import pytz
for i in range(9):
utc_dt = datetime.datetime(2014, 3, 9, i, 0, tzinfo=pytz.timezone('UTC'))
tz_dt = datetime.datetime(2014, 3, 9, i, 0, tzinfo=pytz.timezone('US/Eastern'))
utc_ts = pd.Timestamp(utc_dt)
tz_ts = pd.Timestamp(tz_dt)
print(utc_ts, tz_ts)
print(utc_ts.value == pd.tslib.tz_convert_single(tz_ts.value, pytz.timezone('UTC'),
pytz.timezone('US/Eastern')))
print(tz_ts.value == pd.tslib.tz_convert_single(utc_ts.value, pytz.timezone('US/Eastern'),
pytz.timezone('UTC')))
Current Result
(Timestamp('2014-03-09 00:00:00+0000', tz='UTC'), Timestamp('2014-03-09 00:00:00-0500', tz='US/Eastern'))
True
True
(Timestamp('2014-03-09 01:00:00+0000', tz='UTC'), Timestamp('2014-03-09 01:00:00-0500', tz='US/Eastern'))
True
True
(Timestamp('2014-03-09 02:00:00+0000', tz='UTC'), Timestamp('2014-03-09 02:00:00-0500', tz='US/Eastern'))
True
True
(Timestamp('2014-03-09 03:00:00+0000', tz='UTC'), Timestamp('2014-03-09 03:00:00-0500', tz='US/Eastern'))
False
True
(Timestamp('2014-03-09 04:00:00+0000', tz='UTC'), Timestamp('2014-03-09 04:00:00-0500', tz='US/Eastern'))
False
True
(Timestamp('2014-03-09 05:00:00+0000', tz='UTC'), Timestamp('2014-03-09 05:00:00-0500', tz='US/Eastern'))
False
True
(Timestamp('2014-03-09 06:00:00+0000', tz='UTC'), Timestamp('2014-03-09 06:00:00-0500', tz='US/Eastern'))
False
True
(Timestamp('2014-03-09 07:00:00+0000', tz='UTC'), Timestamp('2014-03-09 07:00:00-0500', tz='US/Eastern'))
False
True
(Timestamp('2014-03-09 08:00:00+0000', tz='UTC'), Timestamp('2014-03-09 08:00:00-0500', tz='US/Eastern'))
False
False