Skip to content

Series[datetime64tz] - DatetimeIndex[tz] raises ValueError #19071

Closed
@jbrockmendel

Description

@jbrockmendel

Opening an issue mostly so the upcoming PR can reference it. This is in fact already fixed in master (at least as of 9303315), so the PR is just a test.

Setup:

dti = pd.date_range('1999-09-30', periods=10, tz='US/Pacific')
ser = pd.Series(dti)

0.22.0:

>>> ser - dti
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 720, in wrapper
    converted = _Op.get_op(left, right, name, na_op)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 349, in get_op
    return _TimeOp(left, right, name, na_op)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 385, in __init__
    self._validate(lvalues, rvalues, name)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 444, in _validate
    raise ValueError("Incompatible tz's on datetime subtraction "
ValueError: Incompatible tz's on datetime subtraction ops

>>> dti - ser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 720, in wrapper
    converted = _Op.get_op(left, right, name, na_op)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 349, in get_op
    return _TimeOp(left, right, name, na_op)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 385, in __init__
    self._validate(lvalues, rvalues, name)
  File "/usr/local/lib/python2.7/site-packages/pandas/core/ops.py", line 444, in _validate
    raise ValueError("Incompatible tz's on datetime subtraction "
ValueError: Incompatible tz's on datetime subtraction ops

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions