Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,25 @@ def test_loc_getitem_single_boolean_arg(self, obj, key, exp):
else:
assert res == exp

@pytest.mark.parametrize(
"data",
[
[datetime(2025, 10, 30)],
[Timestamp(2025, 10, 30)] * 2,
[Timedelta(1)],
[Timedelta(1), Timedelta(2)],
],
)
def test_loc_empty_slice_assignment_with_datetime(self, data):
# issue #50942
# empty slice assignment with datetime or timedelta should not raise exceptions
mask = [False] * len(data)

df = DataFrame(data=data, columns=["A"])
expected = df.copy()
df.loc[mask] = df
tm.assert_frame_equal(df, expected)


class TestLocBaseIndependent:
# Tests for loc that do not depend on subclassing Base
Expand Down
Loading