-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: Remove special-casing for date objects in DatetimeIndex indexing (GH#62158) #62198
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
base: main
Are you sure you want to change the base?
Changes from 27 commits
761ac0e
29662c0
2f98bd4
69ae807
7441046
149b9c4
6c8b76a
0a0f582
30a87b4
f8e4974
610868f
6583c57
1c59ae7
19d0357
ea62b68
d03cb23
dd0278c
7371adc
5df34b5
598f762
f60be17
be5528e
76c93e4
0c7eb2d
0d81824
8f39dbc
2e6764c
8ff37c6
48595e1
c4ff5e2
0f7f3b8
3b38f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,6 @@ | |
| no_default, | ||
| ) | ||
| from pandas._libs.tslibs import ( | ||
| OutOfBoundsDatetime, | ||
| Timestamp, | ||
| tz_compare, | ||
| ) | ||
|
|
@@ -6204,11 +6203,6 @@ def _maybe_downcast_for_indexing(self, other: Index) -> tuple[Index, Index]: | |
| # standardize on UTC | ||
| return self.tz_convert("UTC"), other.tz_convert("UTC") | ||
|
|
||
| elif self.inferred_type == "date" and isinstance(other, ABCDatetimeIndex): | ||
| try: | ||
| return type(other)(self), other | ||
| except OutOfBoundsDatetime: | ||
| return self, other | ||
| elif self.inferred_type == "timedelta" and isinstance(other, ABCTimedeltaIndex): | ||
| # TODO: we dont have tests that get here | ||
| return type(other)(self), other | ||
|
|
@@ -6309,6 +6303,21 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool: | |
| return dtype.kind == "b" | ||
| elif is_numeric_dtype(self.dtype): | ||
| return is_numeric_dtype(dtype) | ||
| # GH#62158 | ||
| elif isinstance(dtype, ArrowDtype): | ||
| import pyarrow as pa | ||
|
|
||
| if dtype.kind != "M": | ||
| return False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems weird. wouldn't this return False if both are int64 dtypes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i added checks inside the arrow dtype, also in |
||
| pa_dtype = dtype.pyarrow_dtype | ||
| if pa.types.is_date(pa_dtype): | ||
| return False | ||
| if pa.types.is_timestamp(pa_dtype): | ||
| if (getattr(pa_dtype, "tz", None) is None) ^ ( | ||
|
||
| getattr(self, "tz", None) is None | ||
| ): | ||
| return False | ||
| return True | ||
| # TODO: this was written assuming we only get here with object-dtype, | ||
| # which is no longer correct. Can we specialize for EA? | ||
| return True | ||
|
|
||
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.
shouldn't this depend on self.dtype?
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 have updated with
self.dtype.kindordtype.kind, please correct me if i should only use self.dtype.kind