Skip to content

Weekly anchored frequency offsets don't behave as expected #1839

Closed
@ijmcf

Description

@ijmcf

For example:

period_index = pandas.period_range('2012/6/3', periods=10, freq='W-FRI')
<class 'pandas.tseries.period.PeriodIndex'>
freq: W-FRI
[02-Jun-2012/08-Jun-2012, ..., 04-Aug-2012/10-Aug-2012]
length: 10

Although the frequency is "W-FRI", the start dates listed (02-Jun-2012, ..., 04-Aug-2012) are Saturdays.

Converting the frequency of the PeriodIndex to daily using "start", you get Saturdays:

period_index.asfreq(freq='D', how='start')
<class 'pandas.tseries.period.PeriodIndex'>
freq: D
[02-Jun-2012, ..., 04-Aug-2012]
length: 10

And if you convert the PeriodIndex to a DatetimeIndex using to_timestamp(), you get a frequency that is explicitly "W-SAT":

period_index.to_timestamp(freq='D', how='s')
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-06-02 00:00:00, ..., 2012-08-04 00:00:00]
Length: 10, Freq: W-SAT, Timezone: None

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