Skip to content

Commit 4ba7f9a

Browse files
authored
TST #22663: Operation between DataFrame with non-numeric types and incomplete series (#34517)
1 parent 9a57f45 commit 4ba7f9a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/frame/test_arithmetic.py

+15
Original file line numberDiff line numberDiff line change
@@ -1536,3 +1536,18 @@ def test_dataframe_blockwise_slicelike():
15361536

15371537
expected = pd.DataFrame({i: left[i] + right[i] for i in left.columns})
15381538
tm.assert_frame_equal(res, expected)
1539+
1540+
1541+
@pytest.mark.parametrize(
1542+
"df, col_dtype",
1543+
[
1544+
(pd.DataFrame([[1.0, 2.0], [4.0, 5.0]], columns=list("ab")), "float64"),
1545+
(pd.DataFrame([[1.0, "b"], [4.0, "b"]], columns=list("ab")), "object"),
1546+
],
1547+
)
1548+
def test_dataframe_operation_with_non_numeric_types(df, col_dtype):
1549+
# GH #22663
1550+
expected = pd.DataFrame([[0.0, np.nan], [3.0, np.nan]], columns=list("ab"))
1551+
expected = expected.astype({"b": col_dtype})
1552+
result = df + pd.Series([-1.0], index=list("a"))
1553+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)