Skip to content

Commit 4f9b3ea

Browse files
authored
TST: test selection methods after assignment with at (#43843)
1 parent ef31301 commit 4f9b3ea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/indexing/test_at.py

+21
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ def test_at_timezone():
2626
tm.assert_frame_equal(result, expected)
2727

2828

29+
def test_selection_methods_of_assigned_col():
30+
# GH 29282
31+
df = DataFrame(data={"a": [1, 2, 3], "b": [4, 5, 6]})
32+
df2 = DataFrame(data={"c": [7, 8, 9]}, index=[2, 1, 0])
33+
df["c"] = df2["c"]
34+
df.at[1, "c"] = 11
35+
result = df
36+
expected = DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [9, 11, 7]})
37+
tm.assert_frame_equal(result, expected)
38+
result = df.at[1, "c"]
39+
assert result == 11
40+
41+
result = df["c"]
42+
expected = Series([9, 11, 7], name="c")
43+
tm.assert_series_equal(result, expected)
44+
45+
result = df[["c"]]
46+
expected = DataFrame({"c": [9, 11, 7]})
47+
tm.assert_frame_equal(result, expected)
48+
49+
2950
class TestAtSetItem:
3051
def test_at_setitem_mixed_index_assignment(self):
3152
# GH#19860

0 commit comments

Comments
 (0)