Skip to content

Commit 4c3cffd

Browse files
srkdsim-vinicius
authored and
im-vinicius
committed
TST: cast string to complex (pandas-dev#52855)
1 parent b779f43 commit 4c3cffd

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
@@ -1162,6 +1162,13 @@ def test_compare_complex_dtypes():
11621162
df.lt(df.astype(object))
11631163

11641164

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

0 commit comments

Comments
 (0)