-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: share IntervalIndex.intersection with Index.intersection #38373
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
Conversation
nice! |
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.
Can you also add tests for concat with interval dtypes? (that will also be affected by this change)
def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]: | ||
# NB: this doesn't handle checking for closed match | ||
if not all(isinstance(x, IntervalDtype) for x in dtypes): | ||
return np.dtype(object) |
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.
This is the wrong return value, see docstring in the base class:
pandas/pandas/core/dtypes/base.py
Lines 326 to 346 in 36c4d5c
def _get_common_dtype(self, dtypes: List[DtypeObj]) -> Optional[DtypeObj]: | |
""" | |
Return the common dtype, if one exists. | |
Used in `find_common_type` implementation. This is for example used | |
to determine the resulting dtype in a concat operation. | |
If no common dtype exists, return None (which gives the other dtypes | |
the chance to determine a common dtype). If all dtypes in the list | |
return None, then the common dtype will be "object" dtype (this means | |
it is never needed to return "object" dtype from this method itself). | |
Parameters | |
---------- | |
dtypes : list of dtypes | |
The dtypes for which to determine a common dtype. This is a list | |
of np.dtype or ExtensionDtype instances. | |
Returns | |
------- | |
Common dtype (np.dtype or ExtensionDtype) or None |
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.
thanks, will address in follow-up
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This changes the return dtype of IntervalIndex.intersection when that intersection is empty.