Skip to content

Timestamp.replace should handle DST transition gracefully #18319

Closed
@jbrockmendel

Description

@jbrockmendel

In fairness, datetime doesn't handle this any better, and differing from that behavior could be considered a drawback.

>>> ts = pd.Timestamp('1929-05-05', tz='US/Eastern')
>>> res = ts.replace(month=4)
>>> expected = pd.Timestamp('1929-04-05', tz='US/Eastern')
>>> res == expected
False
>>> expected.tzinfo.normalize(expected) == expected
True
>>> res.tzinfo.normalize(res) == res
False
>>> res.tzinfo.normalize(res)
Timestamp('1929-04-04 22:00:00-0500', tz='US/Eastern')

Is this a feature and not a bug for some reason I'm missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions