Skip to content

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

Merged
merged 9 commits into from
Apr 19, 2023

Conversation

jbrockmendel
Copy link
Member

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.

@@ -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`)
Copy link
Member

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.

Copy link
Member Author

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

@mroeschke mroeschke added the Deprecate Functionality to remove in pandas label Apr 14, 2023
@jbrockmendel jbrockmendel changed the title DEPR: is_datetime64_any_dtype PERF: avoid is_datetime64_any_dtype Apr 17, 2023
@jbrockmendel jbrockmendel added Performance Memory or execution speed performance and removed Deprecate Functionality to remove in pandas labels Apr 17, 2023
@jbrockmendel
Copy link
Member Author

reverted deprecation, so this is just avoiding internal usages

@mroeschke mroeschke added this to the 2.1 milestone Apr 18, 2023
@@ -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":
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will revert

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated + green

@@ -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":
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

un-reverted + green

@mroeschke mroeschke merged commit 38271a4 into pandas-dev:main Apr 19, 2023
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the ref-is_datetime64_any_dtype branch April 19, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants