Skip to content

Commit 3814b8d

Browse files
Initial version
1 parent ce123cd commit 3814b8d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/whatsnew/v1.5.3.rst

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Bug fixes
3333
- Bug when chaining several :meth:`.Styler.concat` calls, only the last styler was concatenated (:issue:`49207`)
3434
- Fixed bug when instantiating a :class:`DataFrame` subclass inheriting from ``typing.Generic`` that triggered a ``UserWarning`` on python 3.11 (:issue:`49649`)
3535
- Bug in :func:`pandas.testing.assert_series_equal` (and equivalent ``assert_`` functions) when having nested data and using numpy >= 1.25 (:issue:`50360`)
36+
- Bug in :meth:`DataFrame.loc` leading to unwanted `FutureWarning` (:issue:`48673`)
3637
-
3738

3839
.. ---------------------------------------------------------------------------

pandas/core/indexing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2026,11 +2026,12 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
20262026
"array. To retain the old behavior, use either "
20272027
"`df[df.columns[i]] = newvals` or, if columns are non-unique, "
20282028
"`df.isetitem(i, newvals)`",
2029-
FutureWarning,
2029+
DeprecationWarning,
20302030
stacklevel=find_stack_level(),
20312031
)
20322032
# TODO: how to get future behavior?
20332033
# TODO: what if we got here indirectly via loc?
2034+
pass
20342035
return
20352036

20362037
def _setitem_single_block(self, indexer, value, name: str):

pandas/tests/indexing/test_loc.py

+8
Original file line numberDiff line numberDiff line change
@@ -3211,3 +3211,11 @@ def test_getitem_loc_str_periodindex(self):
32113211
index = pd.period_range(start="2000", periods=20, freq="B")
32123212
series = Series(range(20), index=index)
32133213
assert series.loc["2000-01-14"] == 9
3214+
3215+
def test_deprecation_warnings_raised_loc(self):
3216+
# GH#48673
3217+
with tm.assert_produces_warning(DeprecationWarning):
3218+
values = np.arange(4).reshape(2, 2)
3219+
df = DataFrame(values, columns=["a", "b"])
3220+
new = np.array([10, 11]).astype(np.int16)
3221+
df.loc[:, "a"] = new

0 commit comments

Comments
 (0)