Skip to content

Period(weekend_date, 'B') returns Monday's Period #10575

@max-sixty

Description

@max-sixty

The asof docs state that the method should return the most recent label up to and including the passed label. For period indexes, this doesn't seem to be happening - if I supply a period of a weekend date to a weekday series, it returns the Monday, rather than the Friday.

If I do the same on a DatetimeIndex, it behaves as expected

In [50]:
dates

Out[50]:
<class 'pandas.tseries.period.PeriodIndex'>
[1990-05-07, ..., 2015-07-13]
Length: 6568, Freq: B

In [51]:
dates_ts=dates.to_timestamp()
dates_ts

Out[51]:
<class 'pandas.tseries.index.DatetimeIndex'>
[1990-05-07, ..., 2015-07-13]
Length: 6568, Freq: None, Timezone: None

In [52]:
dates.asof('2015-07-11')

Out[52]:
Period('2015-07-13', 'B')

In [53]:
dates_ts.asof('2015-07-11')

Out[53]:
Timestamp('2015-07-10 00:00:00')

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselvesPeriodPeriod data type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions