Skip to content

Commit 07ca91a

Browse files
rhshadrachmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#48324: BUG: Add note in whatsnew for DataFrame.at behavior change
1 parent 401c32b commit 07ca91a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

doc/source/whatsnew/v1.5.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ Indexing
10811081
- Bug in :meth:`DataFrame.sum` min_count changes dtype if input contains NaNs (:issue:`46947`)
10821082
- Bug in :class:`IntervalTree` that lead to an infinite recursion. (:issue:`46658`)
10831083
- Bug in :class:`PeriodIndex` raising ``AttributeError`` when indexing on ``NA``, rather than putting ``NaT`` in its place. (:issue:`46673`)
1084-
-
1084+
- Bug in :meth:`DataFrame.at` would allow the modification of multiple columns (:issue:`48296`)
10851085

10861086
Missing
10871087
^^^^^^^

pandas/tests/indexing/test_at.py

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import numpy as np
77
import pytest
88

9+
from pandas.errors import InvalidIndexError
10+
911
from pandas import (
1012
CategoricalDtype,
1113
CategoricalIndex,
@@ -192,6 +194,12 @@ def test_at_frame_raises_key_error2(self, indexer_al):
192194
with pytest.raises(KeyError, match="^0$"):
193195
indexer_al(df)["a", 0]
194196

197+
def test_at_frame_multiple_columns(self):
198+
# GH#48296 - at shouldn't modify multiple columns
199+
df = DataFrame({"a": [1, 2], "b": [3, 4]})
200+
with pytest.raises(InvalidIndexError, match=r"slice\(None, None, None\)"):
201+
df.at[5] = [6, 7]
202+
195203
def test_at_getitem_mixed_index_no_fallback(self):
196204
# GH#19860
197205
ser = Series([1, 2, 3, 4, 5], index=["a", "b", "c", 1, 2])

0 commit comments

Comments
 (0)