Skip to content

Commit 6033ed4

Browse files
authored
BUG: Categorical of booleans has object .categories (#46422)
* TST: tests added pre GH46313 * Revert "TST: tests added pre GH46313" This reverts commit a5a0a29. * TST:test added for GH46313 * file reformated
1 parent b14d62e commit 6033ed4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/series/accessors/test_cat_accessor.py

+9
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,12 @@ def test_set_categories_setitem(self):
282282
# values should not be coerced to NaN
283283
assert list(df["Sex"]) == ["female", "male", "male"]
284284
assert list(df["Survived"]) == ["Yes", "No", "Yes"]
285+
286+
def test_categorical_of_booleans_is_boolean(self):
287+
# https://github.com/pandas-dev/pandas/issues/46313
288+
df = DataFrame(
289+
{"int_cat": [1, 2, 3], "bool_cat": [True, False, False]}, dtype="category"
290+
)
291+
value = df["bool_cat"].cat.categories.dtype
292+
expected = np.dtype(np.bool_)
293+
assert value is expected

0 commit comments

Comments
 (0)