Closed
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
dti = pd.date_range("2021-10-18", periods=9, freq="B")
pi = dti.to_period()
roundtrip = pi[::2].to_timestamp() # should match dti[::2] (except for roundtrip.freq)
>>> roundtrip
DatetimeIndex(['2021-10-18', '2021-10-19', '2021-10-20', '2021-10-21',
'2021-10-22'],
dtype='datetime64[ns]', freq='D')
>>> roundtrip - dti[::2] # should be timedelta-zeros
TimedeltaIndex(['0 days', '-1 days', '-2 days', '-5 days', '-6 days'], dtype='timedelta64[ns]', freq=None)
Issue Description
PeriodArray.to_timestamp is returning incorrect results. Haven't checked if Period is affected, or other freqs.
Expected Behavior
assert (roundtrip == dti[::2]).all()
Installed Versions
Replace this line with the output of pd.show_versions()