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.
Comment From: jreback
this is a dupe of #11679
Comment From: jzwinck
@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?
Comment From: jreback
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
Comment From: jreback
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.)