Skip to content

BUG: Handle Day offset in to_timedelta #64306

Open
An1k4et wants to merge 6 commits intopandas-dev:mainfrom
An1k4et:fix-timedelta
Open

BUG: Handle Day offset in to_timedelta #64306
An1k4et wants to merge 6 commits intopandas-dev:mainfrom
An1k4et:fix-timedelta

Conversation

@An1k4et
Copy link

@An1k4et An1k4et commented Feb 25, 2026

Summary

My solution makes to_timedelta correctly handle the Day offset.
now, when a Day object is passed, it converts it into a Timedelta using the number of days it contains.

Note: AI used to track exact file location of issue and understand issue.


def test_to_timedelta_day_offset(self):
result = to_timedelta(to_offset("D"))
expected = pd.Timedelta(days=1)
Copy link
Member

Choose a reason for hiding this comment

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

do we have tests that pd.Timedelta(day_offset) works?

Copy link
Author

@An1k4et An1k4et Feb 27, 2026

Choose a reason for hiding this comment

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

I checked this - pd.Timedelta(day_offset) currently does not work

I specifically fixes the handling in to_timedelta. I can look into exetending support in the constructor as well.
Let me know if that would be preferred.

@jbrockmendel
Copy link
Member

Does this work with a list of day_offsets?

@An1k4et
Copy link
Author

An1k4et commented Feb 27, 2026

List-like input not handled previously,
i will update the implementation to normalize day offset before list-like conversion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants