pandas icon indicating copy to clipboard operation
pandas copied to clipboard

BUG: Fix dt64[non_nano] + some_offsets incorrectly rounding

Open Aniketsy opened this issue 3 months ago • 2 comments

  • [ ] closes #56586 (Replace xxxx with the GitHub issue number)
  • [ ] Tests added and passed if fixing a bug or adding a new feature

This PR updates logic selects the finest unit between the array and the offset, preventing rounding errors. A regression test is included to confirm correct behavior for affected offsets and units.

Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions. Thankyou !

Aniketsy avatar Sep 19 '25 21:09 Aniketsy

Hi @jbrockmendel I think i might be a bit lost here. Could you please guide me if i’m heading in the wrong direction? Thank you!

Aniketsy avatar Oct 26 '25 10:10 Aniketsy

@jbrockmendel Thanks for the review and the corrections. Only one test failure is left now.

FAILED pandas/tests/arrays/test_datetimes.py::test_dt64_non_nano_offset_no_rounding - AttributeError: 'datetime.datetime' object has no attribute 'tz_localize'

Aniketsy avatar Nov 22 '25 07:11 Aniketsy

I’m a bit confused about this assertion error, it shows up in ci, but I’m unable to reproduce it locally.

0.01s call     pandas/tests/arrays/test_datetimes.py::TestDatetimeArray::test_iter_zoneinfo_fold[pytz/US/Eastern]
0.01s call     pandas/tests/arrays/test_datetimes.py::test_dt64_non_nano_offset_no_rounding
============================ 2474 passed in 11.70s ============================= 

Aniketsy avatar Dec 18 '25 18:12 Aniketsy