Skip to content

Commit 8e368b1

Browse files
colevoncolecolevoncole
colevoncole
authored and
colevoncole
committed
Changed Warning to DeprecationWarning
1 parent 732bf05 commit 8e368b1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pandas/core/indexing.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ def _setitem_with_indexer_frame_value(self, indexer, value: DataFrame, name: str
19621962

19631963
self._setitem_single_column(loc, val, pi)
19641964

1965-
def _setitem_single_column(self, loc: int, value, plane_indexer) -> None:
1965+
def _setitem_single_column(self, loc: int, value, plane_indexer, is_iloc = False) -> None:
19661966
"""
19671967
19681968
Parameters
@@ -2028,6 +2028,15 @@ def _setitem_single_column(self, loc: int, value, plane_indexer) -> None:
20282028
# warn either
20292029
pass
20302030
else:
2031+
warnings.warn(
2032+
"In a future version, `df.iloc[:, i] = newvals` will attempt "
2033+
"to set the values inplace instead of always setting a new "
2034+
"array. To retain the old behavior, use either "
2035+
"`df[df.columns[i]] = newvals` or, if columns are non-unique, "
2036+
"`df.isetitem(i, newvals)`",
2037+
DeprecationWarning,
2038+
stacklevel=find_stack_level(),
2039+
)
20312040
# TODO: how to get future behavior?
20322041
# TODO: what if we got here indirectly via loc?
20332042
pass

pandas/tests/indexing/test_loc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3221,9 +3221,9 @@ def test_getitem_loc_str_periodindex(self):
32213221
series = Series(range(20), index=index)
32223222
assert series.loc["2000-01-14"] == 9
32233223

3224-
def test_no_warnings_raised_loc(self):
3224+
def test_deprecation_warnings_raised_loc(self):
32253225
# GH#48673
3226-
with tm.assert_produces_warning(None):
3226+
with tm.assert_produces_warning(DeprecationWarning):
32273227
values = np.arange(4).reshape(2, 2)
32283228
df = DataFrame(values, columns=["a", "b"])
32293229
new = np.array([10, 11]).astype(np.int16)

0 commit comments

Comments
 (0)