diff --git a/pandas/tests/dtypes/test_dtypes.py b/pandas/tests/dtypes/test_dtypes.py index 155c61508b706..07a4e06db2e74 100644 --- a/pandas/tests/dtypes/test_dtypes.py +++ b/pandas/tests/dtypes/test_dtypes.py @@ -1174,6 +1174,15 @@ def test_cast_string_to_complex(): tm.assert_frame_equal(result, expected) +def test_categorical_complex(): + result = Categorical([1, 2 + 2j]) + expected = Categorical([1.0 + 0.0j, 2.0 + 2.0j]) + tm.assert_categorical_equal(result, expected) + result = Categorical([1, 2, 2 + 2j]) + expected = Categorical([1.0 + 0.0j, 2.0 + 0.0j, 2.0 + 2.0j]) + tm.assert_categorical_equal(result, expected) + + def test_multi_column_dtype_assignment(): # GH #27583 df = pd.DataFrame({"a": [0.0], "b": 0.0})