Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: DatetimeIndex cast to object dtype raises/wrong for tzaware #23491

Closed
jbrockmendel opened this issue Nov 4, 2018 · 0 comments · Fixed by #23524
Closed

BUG: DatetimeIndex cast to object dtype raises/wrong for tzaware #23491

jbrockmendel opened this issue Nov 4, 2018 · 0 comments · Fixed by #23524
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype Timezones Timezone data dtype
Milestone

Comments

@jbrockmendel
Copy link
Member

dti = pd.date_range('2016-01-01', periods=3, tz='US/Central')

>>> pd.Index(dti, dtype=object)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexes/base.py", line 294, in __new__
    dtype=dtype, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/indexes/datetimes.py", line 453, in __new__
    raise ValueError("cannot localize from non-UTC data")
ValueError: cannot localize from non-UTC data

>>> np.array(dti, dtype=object)
array([1451628000000000000L, 1451714400000000000L, 1451800800000000000L],
      dtype=object)

I expected these to match pd.Index(list(dti), dtype=object) and np.array(list(dti)), respectively.

@gfyoung gfyoung added Datetime Datetime data dtype Compat pandas objects compatability with Numpy or Python functions labels Nov 4, 2018
@mroeschke mroeschke added the Timezones Timezone data dtype label Nov 4, 2018
@jreback jreback added this to the 0.24.0 milestone Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Datetime Datetime data dtype Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants