Skip to content

Commit 99f8d5d

Browse files
committed
fix categorical dtype warning
1 parent cdaac04 commit 99f8d5d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pasteur/extras/transformers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44
import pandas as pd
5-
from pandas.api.types import is_categorical_dtype, is_float_dtype
5+
from pandas.api.types import is_float_dtype
66

77
from pasteur.attribute import Attributes
88
from pasteur.transform import RefTransformer, Transformer
@@ -147,7 +147,7 @@ def transform(self, data: pd.Series) -> pd.DataFrame:
147147
out_col = data.map(mapping)
148148

149149
# Handle categorical columns without blowing them up to full blown columns
150-
if is_categorical_dtype(out_col):
150+
if isinstance(out_col, pd.CategoricalDtype):
151151
out_col = out_col.cat.add_categories(range(self.ofs))
152152

153153
# Handle NAs correctly
@@ -166,7 +166,7 @@ def transform(self, data: pd.Series) -> pd.DataFrame:
166166
), f"Uknown values found in '{self.col}', but no unknown value provided."
167167

168168
# Remove old categories to change dtype
169-
if is_categorical_dtype(out_col):
169+
if isinstance(out_col, pd.CategoricalDtype):
170170
out_col = out_col.cat.set_categories(range(self.domain))
171171

172172
return pd.DataFrame(out_col.astype(type))

0 commit comments

Comments
 (0)