", l...">

API: tz_convert within DatetimeIndex constructor · Issue #23579 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@jbrockmendel

Description

@jbrockmendel

At the moment the following raises:

>>> dti = pd.date_range('2016-01-01', periods=3, tz='US/Central')
>>> pd.DatetimeIndex(dti, tz='Asia/Tokyo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexes/datetimes.py", line 413, in __new__
    raise TypeError(msg.format(data.tz, tz))
TypeError: data is already tz-aware US/Central, unable to set specified tz: Asia/Tokyo

It isn't clear to me that raising is the right thing to do; shouldn't this just be equivalent to dti.tz_convert('Asia/Tokyo')? Or is this ambiguous for some reason?