Skip to content

Commit 409a3c8

Browse files
matttan90proost
authored andcommitted
TST: Test for Boolean Series with missing to Categorical dtype (pandas-dev#29344)
1 parent e50d7a3 commit 409a3c8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/series/test_dtypes.py

+9
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,15 @@ def test_astype_categorical_to_categorical(
377377
result = s.astype("category")
378378
tm.assert_series_equal(result, expected)
379379

380+
def test_astype_bool_missing_to_categorical(self):
381+
# GH-19182
382+
s = Series([True, False, np.nan])
383+
assert s.dtypes == np.object_
384+
385+
result = s.astype(CategoricalDtype(categories=[True, False]))
386+
expected = Series(Categorical([True, False, np.nan], categories=[True, False]))
387+
tm.assert_series_equal(result, expected)
388+
380389
def test_astype_categoricaldtype(self):
381390
s = Series(["a", "b", "a"])
382391
result = s.astype(CategoricalDtype(["a", "b"], ordered=True))

0 commit comments

Comments
 (0)