Skip to content

Commit 5df8f82

Browse files
authored
REF: test_mutate_columns -> test_setitem (#33193)
1 parent e4c17f7 commit 5df8f82

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pandas/tests/frame/test_mutate_columns.py renamed to pandas/tests/frame/indexing/test_setitem.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas import DataFrame, Series
4+
from pandas import DataFrame, Index, Series
55
import pandas._testing as tm
66

77
# Column add, remove, delete.
@@ -12,14 +12,17 @@ def test_setitem_error_msmgs(self):
1212

1313
# GH 7432
1414
df = DataFrame(
15-
{"foo": ["a", "b", "c"], "bar": [1, 2, 3], "baz": ["d", "e", "f"]}
16-
).set_index("foo")
17-
s = DataFrame(
18-
{"foo": ["a", "b", "c", "a"], "fiz": ["g", "h", "i", "j"]}
19-
).set_index("foo")
15+
{"bar": [1, 2, 3], "baz": ["d", "e", "f"]},
16+
index=Index(["a", "b", "c"], name="foo"),
17+
)
18+
ser = Series(
19+
["g", "h", "i", "j"],
20+
index=Index(["a", "b", "c", "a"], name="foo"),
21+
name="fiz",
22+
)
2023
msg = "cannot reindex from a duplicate axis"
2124
with pytest.raises(ValueError, match=msg):
22-
df["newcol"] = s
25+
df["newcol"] = ser
2326

2427
# GH 4107, more descriptive error message
2528
df = DataFrame(np.random.randint(0, 2, (4, 4)), columns=["a", "b", "c", "d"])

0 commit comments

Comments
 (0)