BUG: Block/DTI doesnt handle tzlocal properly by sinhrks · Pull Request #13583 · pandas-dev/pandas (original) (raw)
- tests added / passed
- passes
git diff upstream/master | flake8 --diff
- whatsnew entry
Unable to concatenate Series
with tzlocal
s = pd.Series([pd.Timestamp('2011-01-01', tz=dateutil.tz.tzlocal())])
s
#0 2011-01-01 00:00:00+09:00
# dtype: datetime64[ns, tzlocal()]
pd.concat([s, s])
# UnknownTimeZoneError: 'tzlocal()'
It is caused by 2 issues:
1. tslib.maybe_get_tz
can't handle tzlocal
.
pd.tslib.maybe_get_tz('tzlocal()')
# UnknownTimeZoneError: 'tzlocal()'
2. DatetimeIndex.tz_localize
may return incorrect result when tzlocal
is used.
it's internally used in conat
.
pd.DatetimeIndex(['2011-01-01', '2011-01-02'], tz=dateutil.tz.tzlocal()).tz_localize(None)
# DatetimeIndex(['2011-01-01', '1970-01-01'], dtype='datetime64[ns]', freq=None)