From 62884d7bd3162a31df78e553bac50811f504909e Mon Sep 17 00:00:00 2001 From: quant12345 Date: Tue, 16 Jul 2024 20:29:23 +0500 Subject: [PATCH] fix: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, pd.CategoricalDtype) --- src/ydata_profiling/model/typeset.py | 8 ++++---- src/ydata_profiling/model/typeset_relations.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ydata_profiling/model/typeset.py b/src/ydata_profiling/model/typeset.py index 65f0cd2d6..a8e5b9f2e 100644 --- a/src/ydata_profiling/model/typeset.py +++ b/src/ydata_profiling/model/typeset.py @@ -122,7 +122,7 @@ def get_relations() -> Sequence[TypeRelation]: @series_handle_nulls def contains_op(series: pd.Series, state: dict) -> bool: return ( - not pdt.is_categorical_dtype(series) + not isinstance(series.dtype, pd.CategoricalDtype) and pdt.is_string_dtype(series) and series_is_string(series, state) ) @@ -205,9 +205,9 @@ def get_relations() -> Sequence[TypeRelation]: @series_not_empty @series_handle_nulls def contains_op(series: pd.Series, state: dict) -> bool: - is_valid_dtype = pdt.is_categorical_dtype(series) and not pdt.is_bool_dtype( - series - ) + is_valid_dtype = isinstance( + series.dtype, pd.CategoricalDtype + ) and not pdt.is_bool_dtype(series) if is_valid_dtype: return True return False diff --git a/src/ydata_profiling/model/typeset_relations.py b/src/ydata_profiling/model/typeset_relations.py index 1a32526b0..beac15b51 100644 --- a/src/ydata_profiling/model/typeset_relations.py +++ b/src/ydata_profiling/model/typeset_relations.py @@ -31,7 +31,7 @@ def string_is_bool(series: pd.Series, state: dict, k: Dict[str, bool]) -> bool: def tester(s: pd.Series, state: dict) -> bool: return s.str.lower().isin(k.keys()).all() - if pdt.is_categorical_dtype(series): + if isinstance(series.dtype, pd.CategoricalDtype): return False return tester(series, state)