Skip to content

Commit 3d3ca1f

Browse files
debnathshohamfeefladder
authored andcommitted
TST: raising ValueError when inserting one dataframe in another (pandas-dev#42831)
* TST: raising ValueError when inserting one dataframe in another * added GH issue reference * rev msg * included both msgs * updated * Update test_insert.py * Update test_insert.py * Update test_insert.py
1 parent 4eb689b commit 3d3ca1f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/frame/indexing/test_insert.py

+10
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,13 @@ def test_insert_item_cache(self, using_array_manager):
8989
ser.values[0] = 99
9090

9191
assert df.iloc[0, 0] == df[0][0]
92+
93+
def test_insert_frame(self):
94+
# GH#42403
95+
df = DataFrame({"col1": [1, 2], "col2": [3, 4]})
96+
msg = (
97+
"Expected a 1D array, got an array with shape "
98+
r"\(2, 2\)|Wrong number of items passed 2, placement implies 1"
99+
)
100+
with pytest.raises(ValueError, match=msg):
101+
df.insert(1, "newcol", df)

0 commit comments

Comments
 (0)