Skip to content

Behaviour of comparisons between pandas.Timestamp and datetime.date objects changes in Pandas v2.0 #934

@matt-graham

Description

@matt-graham

Pandas v2.0 changes the behaviour of equality comparisons of pandas.Timestamp and datetime.date objects to always compare as unequal (pandas-dev/pandas#36131). For example

import datetime, pandas
print(pandas.Timestamp(2010, 1, 1) == datetime.date(2010, 1, 1))

outputs True in Pandas v1.2.2 and False in v2.0.0.

This causes the assert in tests/test_control_order_of_events.py::test_control_of_ordering_in_the_day

events['date'] = pd.to_datetime(events['date']).dt.date
order_on_day_one = tuple(events.loc[events['date'] == Date(2010, 1, 1), 'id'])
assert order_on_day_one == ("EventForStartOfDay",
"EventForMiddleOfDay",
"EventForSecondToLastAtEndOfDay",
"EventForEndOfDay")

to fail when running with Pandas v2.0.0 as the earlier comparison with a Date object (corresponding to a pandas.Timestamp) no longer behaves as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions