Skip to content

Why does infer_freq raise an error for PeriodIndex? #6771

Open
@jseabold

Description

@jseabold

xref #8466

Can't it just return the freq for you instead of raising an error? Helps with duck typing.

[~/]
[1]: pd.version.version
[1]: '0.13.1-434-gdcbbc59'

[2]: pd.tseries.frequencies.infer_freq(pd.PeriodIndex(['2000-01-01'], freq='D'))

Error message

  File "/home/skipper/src/pandas-skipper/pandas/tseries/frequencies.py", line 656, in infer_freq
    raise TypeError("PeriodIndex given. Check the `freq` attribute "
TypeError: PeriodIndex given. Check the `freq` attribute instead of using infer_freq.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions