Skip to content

COMPAT: tzawareness check behavior is different from stdlib #28507

Closed
@jbrockmendel

Description

@jbrockmendel

Timestamp comparisons raise TypeError in some cases where datetimes do not:

ts = pd.Timestamp.now()
ts2 = ts.tz_localize("UTC")
dt = ts.to_pydatetime()
dt2 = ts2.to_pydatetime()

>>> ts == ts2   # <-- TypeError
>>> dt == dt2
False

The datetime comparison will raise for inequalities, just not == or !=.

Changing this behavior would be an API change, but it would likely simplify a bunch of headaches (including a bug in array_equivalent)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Numeric OperationsArithmetic, Comparison, and Logical operationsTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions