From 993eb85a4ddf09311a551ecc6ed9e43e06799460 Mon Sep 17 00:00:00 2001 From: Liang Yan Date: Wed, 7 Jun 2023 14:38:31 +0800 Subject: [PATCH] TST: Add test for complex categories GH#16399 Signed-off-by: Liang Yan --- pandas/tests/dtypes/test_dtypes.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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})