Skip to content

Commit bc2feac

Browse files
committed
fix test 4
1 parent 63c7450 commit bc2feac

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

rdt/transformers/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def _fill_nan_with_none_series(data):
180180
dtype = data.dtype
181181
if isinstance(dtype, pd.CategoricalDtype):
182182
data = data.cat.add_categories([sentinel])
183+
data = data.fillna(sentinel).replace({sentinel: None})
184+
return pd.Series(pd.Categorical(data, categories=dtype.categories), index=data.index)
183185

184186
return data.fillna(sentinel).replace({sentinel: None})
185187

tests/unit/transformers/test_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ def test__fill_nan_with_none_series():
184184
expected_result_categorical = pd.Series(
185185
pd.Categorical(['a', 'b', 'c', 'd', None], categories=['a', 'b', 'c', 'd'])
186186
)
187-
pd.testing.assert_series_equal(
188-
result_categorical, expected_result_categorical, check_dtype=False
189-
)
187+
pd.testing.assert_series_equal(result_categorical, expected_result_categorical)
190188

191189

192190
def test_fill_nan_with_none_series():

0 commit comments

Comments
 (0)