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 indexing fails at nanosecond precision if timezone is used #13908

Closed
jzwinck opened this issue Aug 4, 2016 · 4 comments
Closed
Labels
Bug Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite Timezones Timezone data dtype

Comments

@jzwinck
Copy link
Contributor

jzwinck commented Aug 4, 2016

DatetimeIndex fails to find its own values if a timezone is used:

index = pd.DatetimeIndex(['2016-06-28 08:30:00.123456789'], dtype='datetime64[ns, America/Chicago]')
df = pd.DataFrame({'a':[10]}, index=index)
df.loc[df.index[0]]

It fails with:

*** KeyError: 'the label [2016-06-28 08:30:00.123456789-05:00] is not in the [index]'

This is impossible.

It works if you use only microseconds rather than nanoseconds, and it works if you don't set a timezone.

Pandas 0.18.1.

@jzwinck jzwinck changed the title DatetimeIndex indexing fails at nanosecond precision if timezone is used BUG: DatetimeIndex indexing fails at nanosecond precision if timezone is used Aug 4, 2016
@jreback
Copy link
Contributor

jreback commented Aug 4, 2016

this is a dupe of #11679

@jreback jreback closed this as completed Aug 4, 2016
@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Timezones Timezone data dtype Duplicate Report Duplicate issue or pull request labels Aug 4, 2016
@jreback jreback added this to the No action milestone Aug 4, 2016
@jzwinck
Copy link
Contributor Author

jzwinck commented Aug 4, 2016

@jreback Are you sure this is a dupe? That issue you referenced does not require the use of nanosecond precision, but seems to be about the times when DST changeovers occur. This bug here does not require DST changeover, but does require nanosecond precision. It seems plausible that the same area of code is responsible for both bugs, but I don't see how the two bugs are the same, or would necessarily be fixed by the same patch. Do you?

@jreback
Copy link
Contributor

jreback commented Aug 4, 2016

I am pretty sure
these are red herrings
the issue is caused by a problem in the indexer
the effect is the same

in any event if you want to do a PR then u can confirm it

df.index[0] in df.index is what's failing

@jreback
Copy link
Contributor

jreback commented Jun 28, 2017

This is fixed on master. If anyone wants to do a PR for the tests would be great. (originally linked to #11679, so that might be closable as well.)

@TomAugspurger TomAugspurger added Testing pandas testing functions or related to the test suite Difficulty Novice labels Jun 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

3 participants