Timestamp.replace should handle DST transition gracefully · Issue #18319 · pandas-dev/pandas (original) (raw)
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?