Skip to content

Bad error message when comparing temporal to non-temporal dtype #25729

@mcrumiller

Description

@mcrumiller

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Issue Description

When comparing temporal to non-temporal types, the message "<x> does not have eq operator" is displayed, which is not a great error message.

import polars as pl

pl.Series([1]).cast(pl.Date) == 1  # or string, or anything else
# NotImplementedError: Series of type Date does not have eq operator

pl.Series([1]).cast(pl.Datetime) == 1
# NotImplementedError: Series of type Datetime(time_unit='us', time_zone=None) does not have eq operator

pl.Series([1]).cast(pl.Duration) == 1
# NotImplementedError: Series of type Duration(time_unit='us') does not have eq operator

pl.Series([1]).cast(pl.Time) == 1
# NotImplementedError: Series of type Time does not have eq operator

Also for other equality operators.

Installed versions

main

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageAwaiting prioritization by a maintainerpythonRelated to Python Polars

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions