-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: #35830 Restore index & slice by date to DatetimeIndex #39380
Conversation
DatetimeIndex has supported indexing by date for many many years. This was broken after 1.0.5. This attempts to restore support by promoting date a non--tz aware datetime at midnight.
I can add more tests for slicing and asof (they work) if this will be considered for merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would be ok with a warning but we deliberately change this as it's incorrect
@@ -552,6 +552,11 @@ def _validate_scalar( | |||
------- | |||
self._scalar_type or NaT | |||
""" | |||
|
|||
if type(value) == date: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this (and the similar test below) be isinstance(value, date)
?
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
Closing as it appears this PR has gotten stale. Let us know if you'd like to continue adding a deprecation warning for this behavior and we'd be happy to reopen. |
#35830 DatetimeIndex has supported indexing by date for many many years. This was broken after 1.0.5. This attempts to restore support by converting a date to Timestamp in
get_loc
and_validate_searchsorted_value
. This restores indexing slicing, andasof
butin
does not work. It seems the best solution would be to do the conversion inDatetimeLikeArrayMixin._validate_scalar
but this breaks a test looking for an expectedFutureWarning
inTestDataFrameIndexing::test_loc_setitem_datetime_coercion
warning aTimestamp
can't be compared to adate