Skip to content

Conversation

@Aryn1102
Copy link
Contributor

The Issue:
When using a MultiIndex where a level has datetime.date objects (object dtype), querying with a np.datetime64 key caused get_loc to perform an unsafe binary search (slice_locs). This failed to filter correctly, returning incorrect rows (e.g., returning both "A" and "B" when requesting "A").

The Fix:
I added a check in get_loc. If the key contains np.datetime64 and the corresponding index level is object dtype, the key is converted to a python object (using .item()) before lookup. This ensures type consistency and correct filtering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Strange behavior when accessing datetime.date index with np.datetime64

1 participant