Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

API: IncompatibleFrequency should subclass TypeError #55782

Copy link
Copy link
Open
@jbrockmendel

Description

@jbrockmendel
Issue body actions

Pandas version checks

  • 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 main branch of pandas.

Reproducible Example

per1 = pd.Period("2016Q1", freq="Q")
per2 = per1.asfreq("M")

>>> per1 < per2
pandas._libs.tslibs.period.IncompatibleFrequency: Input has different freq=M from Period(freq=Q-DEC)

idx = pd.Index([per1, per2])
idx2 = pd.Index([per1, "foo"])

>>> idx.is_monotonic_increasing
pandas._libs.tslibs.period.IncompatibleFrequency: Input has different freq=Q-DEC from Period(freq=M)

>>> idx2.is_monotonic_increasing
False

Issue Description

In general the exception you get from mismatched comparisons should be a TypeError (xref #54847). ATM IncompatibleFrequency subclasses ValueError. Might be worth changing that in 3.0.

Expected Behavior

NA

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.