-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
PERF: avoid is_datetime64_any_dtype #52651
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
PERF: avoid is_datetime64_any_dtype #52651
Conversation
doc/source/whatsnew/v2.1.0.rst
Outdated
@@ -234,6 +234,7 @@ Deprecations | |||
- Deprecated :func:`is_datetime64tz_dtype`, check ``isinstance(dtype, pd.DatetimeTZDtype)`` instead (:issue:`52607`) | |||
- Deprecated unused "closed" and "normalize" keywords in the :class:`DatetimeIndex` constructor (:issue:`52628`) | |||
- Deprecated unused "closed" keyword in the :class:`TimedeltaIndex` constructor (:issue:`52628`) | |||
- Deprecated :func:`is_datetime64_any_dtype`, check for specific dtypes of interest instead (:issue:`52651`) |
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.
Is there a way to keep utility functions that are more complicated to reimplement? A single is instance check is fine, but more complicated things would cause duplication for users.
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 guess. all i really care about is that we dont use this internally. but i do think its a footgun since pretty much anyone who uses it wrote it with only numpy/pd.DatetimeTZDtype in mind
reverted deprecation, so this is just avoiding internal usages |
pandas/core/dtypes/common.py
Outdated
@@ -1219,7 +1219,18 @@ def is_bool_dtype(arr_or_dtype) -> bool: | |||
|
|||
if isinstance(arr_or_dtype, ABCIndex): | |||
# Allow Index[object] that is all-bools or Index["boolean"] | |||
return arr_or_dtype.inferred_type == "boolean" | |||
if arr_or_dtype.inferred_type == "boolean": |
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.
Hmm this looks unrelated. Did a merge conflict go wrong in this PR?
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.
agreed, will revert
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.
Updated + green
pandas/core/dtypes/common.py
Outdated
@@ -1219,18 +1219,7 @@ def is_bool_dtype(arr_or_dtype) -> bool: | |||
|
|||
if isinstance(arr_or_dtype, ABCIndex): | |||
# Allow Index[object] that is all-bools or Index["boolean"] | |||
if arr_or_dtype.inferred_type == "boolean": |
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.
Hmm I thought we wanted to still deprecate this in 2.1?
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.
un-reverted + green
Thanks @jbrockmendel |
This was written with numpy dtypes and DatetimeTZDtype in mind, but will now catch 3rd party and ArrowDtype[timestamp] too, so will be a footgun.