Skip to content

BUG: Inconsistent datetime comparison with Tz  #12601

Closed
@sinhrks

Description

@sinhrks

Related to #8306. On current master, Timestamp comparison results in TypeError if its timezones are different. However, Index and Series implicitly converts tz to GMT

pd.Timestamp('2016-01-01 12:00', tz='US/Eastern') > pd.Timestamp('2016-01-01 08:00')
# TypeError: Cannot compare tz-naive and tz-aware timestamps

# same result as idx.tz_convert(None) > pd.Timestamp('2016-01-01 08:00')
idx = pd.date_range('2016-01-01 12:00', periods=10, freq='H', tz='Asia/Tokyo')
idx > pd.Timestamp('2016-01-01 08:00')
# array([False, False, False, False, False, False,  True,  True,  True,  True], dtype=bool)

Numeric ops raises TypeError as expected.

idx - pd.Timestamp('2016-01-01 08:00')
# TypeError: Timestamp subtraction must have the same timezones or no timezones

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions