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)