Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cc06fb0

Browse files
committedJul 29, 2024
remove old comments, add test
1 parent e2b809a commit cc06fb0

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed
 

‎pandas/core/indexing.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,6 @@ def _maybe_mask_setitem_value(self, indexer, value):
811811
if is_scalar_indexer(icols, self.ndim - 1) and ndim == 1:
812812
# e.g. test_loc_setitem_boolean_mask_allfalse
813813
if len(newkey) == 0:
814-
# FIXME: kludge for test_loc_setitem_boolean_mask_allfalse
815-
# TODO(GH#45333): may be fixed when deprecation is enforced
816-
817814
value = value.iloc[:0]
818815
else:
819816
# test_loc_setitem_ndframe_values_alignment
@@ -834,9 +831,6 @@ def _maybe_mask_setitem_value(self, indexer, value):
834831

835832
elif ndim == 2 and value.shape[1] == 1:
836833
if len(newkey) == 0:
837-
# FIXME: kludge for
838-
# test_loc_setitem_all_false_boolean_two_blocks
839-
# TODO(GH#45333): may be fixed when deprecation is enforced
840834
value = value.iloc[:0]
841835
else:
842836
# test_loc_setitem_ndframe_values_alignment

‎pandas/tests/indexing/test_loc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,7 @@ def test_loc_setitem_multiindex_slice(self):
17471747
)
17481748

17491749
result = Series([1, 1, 1, 1, 1, 1, 1, 1], index=index)
1750-
result.loc[("baz", "one") : ("foo", "two")] = 100
1750+
result.loc[("baz", "one"):("foo", "two")] = 100
17511751

17521752
expected = Series([1, 1, 100, 100, 100, 100, 1, 1], index=index)
17531753

@@ -2764,7 +2764,7 @@ def test_loc_axis_1_slice():
27642764
index=tuple("ABCDEFGHIJ"),
27652765
columns=MultiIndex.from_tuples(cols),
27662766
)
2767-
result = df.loc(axis=1)[(2014, 9) : (2015, 8)]
2767+
result = df.loc(axis=1)[(2014, 9):(2015, 8)]
27682768
expected = DataFrame(
27692769
np.ones((10, 4)),
27702770
index=tuple("ABCDEFGHIJ"),
@@ -3272,3 +3272,8 @@ def test_loc_index_alignment_for_series(self):
32723272
df.loc[:, "a"] = other
32733273
expected = DataFrame({"a": [999, 200], "b": [3, 4]})
32743274
tm.assert_frame_equal(expected, df)
3275+
3276+
def test_loc_assign_to_should_not_raise(self):
3277+
# GH 57735
3278+
df = DataFrame(index=[1, 1, 2, 2], data=["1", "1", "2", "2"])
3279+
df.loc[df[0].str.len() > 1, 0] = df[0]

0 commit comments

Comments
 (0)
Please sign in to comment.