Skip to content

Commit

Permalink
fix: is_categorical_dtype is deprecated and will be removed in a futu…
Browse files Browse the repository at this point in the history
…re version. Use isinstance(dtype, pd.CategoricalDtype)
  • Loading branch information
quant12345 authored and rugk committed Oct 31, 2024
1 parent 4c99b30 commit 62884d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/ydata_profiling/model/typeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ydata_profiling/model/typeset_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 62884d7

Please sign in to comment.