Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jbrockmendel opened this issue Dec 31, 2017 · 1 comment · Fixed by #19013
Closed

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

jbrockmendel opened this issue Dec 31, 2017 · 1 comment · Fixed by #19013
Labels
Bug Datetime Datetime data dtype Timedelta Timedelta data type
Milestone

Comments

@jbrockmendel
Copy link
Member

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
@jreback
Copy link
Contributor

jreback commented Dec 31, 2017

0.21.1 is wrong.

this is correct

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

In [14]: dti
Out[14]: 
DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 01:00:00',
               '2016-01-01 02:00:00'],
              dtype='datetime64[ns]', freq='H')

In [15]: dti + 1
Out[15]: 
DatetimeIndex(['2016-01-01 01:00:00', '2016-01-01 02:00:00',
               '2016-01-01 03:00:00'],
              dtype='datetime64[ns]', freq='H')

@jreback jreback added Bug Difficulty Intermediate Timedelta Timedelta data type Datetime Datetime data dtype labels Dec 31, 2017
@jreback jreback modified the milestones: 2.0, Next Major Release, 0.23.0 Dec 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants