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: invalid construction from repr of dt-aware index #15938

Closed
jreback opened this issue Apr 7, 2017 · 1 comment
Closed

BUG: invalid construction from repr of dt-aware index #15938

jreback opened this issue Apr 7, 2017 · 1 comment
Labels
Bug Datetime Datetime data dtype Timezones Timezone data dtype

Comments

@jreback
Copy link
Contributor

jreback commented Apr 7, 2017

thought we had an issue about this....

The data is converted from string and is tz-aware, then the dtype convert is also applied.

In [1]: dt = pd.date_range('20160101', periods=1, tz='US/Eastern')

In [2]: dt
Out[2]: DatetimeIndex(['2016-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq='D')

In [3]: r = DatetimeIndex(['2016-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq='D')

In [4]: r
Out[4]: DatetimeIndex(['2016-01-01 05:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq='D')

In [5]: dt.equals(r)
Out[5]: False
@jreback jreback added Bug Difficulty Intermediate Datetime Datetime data dtype Timezones Timezone data dtype labels Apr 7, 2017
@jreback jreback added this to the Next Minor Release milestone Apr 7, 2017
@jreback jreback modified the milestones: Interesting Issues, Next Major Release Nov 26, 2017
@mroeschke
Copy link
Member

After #21822 this now raises

In [3]: r = DatetimeIndex(['2016-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq='D')
TypeError: data is already tz-aware pytz.FixedOffset(-300), unable to set specified tz: US/Eastern

Which I argue is correct since the user is attempting to localize the datetime with two methods

  • dtype
  • utcoffset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

2 participants