Skip to content

BUG: PeriodIndex[B].to_timestamp drops missing days #44100

Closed
@jbrockmendel

Description

@jbrockmendel

  • 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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypePeriodPeriod data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions