diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index 5be08f163e6ce..d37eebef5c0c0 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -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 diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index e92f2363b69f1..68d99937f728c 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -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 """