Skip to content

DOC: add api.types.is_dtype_equal into document #61394

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 6 commits into from
May 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ Data type introspection
api.types.is_datetime64_dtype
api.types.is_datetime64_ns_dtype
api.types.is_datetime64tz_dtype
api.types.is_dtype_equal
api.types.is_extension_array_dtype
api.types.is_float_dtype
api.types.is_int64_dtype
Expand Down
18 changes: 16 additions & 2 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,24 +655,38 @@ def is_dtype_equal(source, target) -> bool:

Parameters
----------
source : The first dtype to compare
target : The second dtype to compare
source : type or str
The first dtype to compare.
target : type or str
The second dtype to compare.

Returns
-------
boolean
Whether or not the two dtypes are equal.

See Also
--------
api.types.is_categorical_dtype : Check whether the provided array or dtype
is of the Categorical dtype.
api.types.is_string_dtype : Check whether the provided array or dtype
is of the string dtype.
api.types.is_object_dtype : Check whether an array-like or dtype is of the
object dtype.

Examples
--------
>>> from pandas.api.types import is_dtype_equal
>>> is_dtype_equal(int, float)
False
>>> is_dtype_equal("int", int)
True
>>> is_dtype_equal(object, "category")
False
>>> from pandas.core.dtypes.dtypes import CategoricalDtype
>>> is_dtype_equal(CategoricalDtype(), "category")
True
>>> from pandas.core.dtypes.dtypes import DatetimeTZDtype
>>> is_dtype_equal(DatetimeTZDtype(tz="UTC"), "datetime64")
False
"""
Expand Down
Loading