Skip to content

DatetimeIndex/TimedeltaIndex add/sub zero-dim arrays incorrect #19012

Closed
@jbrockmendel

Description

@jbrockmendel

Opening this mainly to get the appropriate reference for the upcoming PR.

Setup:

dti = pd.date_range('2016-01-01', periods=3, freq='H')
one = np.array(1)

0.21.1:

>>> dti + one
DatetimeIndex(['2016-01-01 00:00:00.000000001',
               '2016-01-01 01:00:00.000000001',
               '2016-01-01 02:00:00.000000001'],
              dtype='datetime64[ns]', freq='H')
>>> dti.freq = None
>>> dti + one
DatetimeIndex(['2016-01-01 00:00:00.000000001',
               '2016-01-01 01:00:00.000000001',
               '2016-01-01 02:00:00.000000001'],
              dtype='datetime64[ns]', freq=None)

Master (see #19011)

>>> dti + one
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/indexes/datetimelike.py", line 685, in __add__
    elif is_offsetlike(other):
  File "pandas/core/dtypes/common.py", line 294, in is_offsetlike
    elif (is_list_like(arr_or_obj) and len(arr_or_obj) and
TypeError: len() of unsized object

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