Skip to content

Conversation

akshat62
Copy link

@akshat62 akshat62 commented Aug 12, 2025

@akshat62 akshat62 changed the title Preserve day freq on DatetimeIndex subtraction BUG: Preserve day freq on DatetimeIndex subtraction Aug 12, 2025
@akshat62 akshat62 force-pushed the bug-62094/freq-required-TimedeltaIndex.shift branch from 7280c6a to ed516d9 Compare August 12, 2025 18:26
@akshat62
Copy link
Author

@mroeschke @jbrockmendel Please review.

- Bug in :meth:`to_datetime` reports incorrect index in case of any failure scenario. (:issue:`58298`)
- Bug in :meth:`to_datetime` with ``format="ISO8601"`` and ``utc=True`` where naive timestamps incorrectly inherited timezone offset from previous timestamps in a series. (:issue:`61389`)
- Bug in :meth:`to_datetime` wrongly converts when ``arg`` is a ``np.datetime64`` object with unit of ``ps``. (:issue:`60341`)
- Bug in subtracting a :class:`Timestamp` from a :class:`DatetimeIndex` with
Copy link
Member

Choose a reason for hiding this comment

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

the note isn't necessary bc the bug is not present in a released version

and isinstance(other, Timestamp)
):
self = cast("DatetimeArray", self)
if (self.tz is None or timezones.is_utc(self.tz)) and (
Copy link
Member

Choose a reason for hiding this comment

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

self.tz is None is implied by lib.is_np_dtype(self.dtype, "M") check above

):
self = cast("DatetimeArray", self)
if (self.tz is None or timezones.is_utc(self.tz)) and (
other.tz is None or timezones.is_utc(other.tz)
Copy link
Member

Choose a reason for hiding this comment

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

other.tz will always be None here

with pytest.raises(NullFrequencyError, match="Cannot shift with no freq"):
tdi.shift(2)

def test_shift_after_dti_sub_timestamp(self):
Copy link
Member

Choose a reason for hiding this comment

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

instead of testing this, test the subtraction op directly in tests.indexes.datetimes.test_arithmetic

@Dr-Irv
Copy link
Contributor

Dr-Irv commented Aug 28, 2025

@akshat62 can you let us know when you will address the comments above??

@jbrockmendel
Copy link
Member

closed by #62214

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: In main, TimedeltaIndex.shift() requires freq in the index, but it may not be available because it was computed

3 participants