Skip to content

Commit fc434c4

Browse files
authored
TST: cast string to complex (#52855)
1 parent 7b710c7 commit fc434c4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/dtypes/test_dtypes.py

+7
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,13 @@ def test_compare_complex_dtypes():
11611161
df.lt(df.astype(object))
11621162

11631163

1164+
def test_cast_string_to_complex():
1165+
# GH 4895
1166+
expected = pd.DataFrame(["1.0+5j", "1.5-3j"], dtype=complex)
1167+
result = pd.DataFrame(["1.0+5j", "1.5-3j"]).astype(complex)
1168+
tm.assert_frame_equal(result, expected)
1169+
1170+
11641171
def test_multi_column_dtype_assignment():
11651172
# GH #27583
11661173
df = pd.DataFrame({"a": [0.0], "b": 0.0})

0 commit comments

Comments
 (0)