Skip to content

Commit 3d7fa82

Browse files
committed
TST: Add test for complex categories GH#16399
Signed-off-by: Liang Yan <[email protected]>
1 parent 3fbf49d commit 3d7fa82

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,13 @@ def test_cast_string_to_complex():
11731173
result = pd.DataFrame(["1.0+5j", "1.5-3j"]).astype(complex)
11741174
tm.assert_frame_equal(result, expected)
11751175

1176+
def test_categorical_complex():
1177+
result = pd.Categorical([1, 2 + 2j])
1178+
expected = pd.Categorical([1.0+0.0j, 2.0+2.0j])
1179+
tm.assert_categorical_equal(result, expected)
1180+
result = pd.Categorical([1, 2, 2 + 2j])
1181+
expected = pd.Categorical([1.0+0.0j, 2.0+0.0j, 2.0+2.0j])
1182+
tm.assert_categorical_equal(result, expected)
11761183

11771184
def test_multi_column_dtype_assignment():
11781185
# GH #27583

0 commit comments

Comments
 (0)