Skip to content

Conversation

@litang99
Copy link

Comment on lines 264 to 267
DataFrame({"A": [datetime(2025, 10, 30)]}),
DataFrame({"A": [Timestamp(2025, 10, 30)] * 2}),
DataFrame({"A": [Timedelta(1)]}),
DataFrame({"A": [Timedelta(1), Timedelta(2)]}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you construct the DataFrame in the body of the test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Oct 31, 2025
Comment on lines +274 to +280
try:
df = DataFrame(data=data, columns=["A"])
res = df.loc[mask]
res = df
tm.assert_frame_equal(res, df)
except Exception:
pytest.fail("loc empty slice assignment raised Exception unexpectedly!")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You can remove the try/except
  2. In the original issue, it's testing a setitem, so this would need to be
expected = df.copy()
df.loc[mask] = df
tm.assert_frame_equal(df, expected) 

@litang99 litang99 requested a review from mroeschke November 5, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: empty slice assignment raises if datetime column is present

2 participants