Skip to content

divide does not work for Series of timedelta64[ns] #6050

Closed
@cancan101

Description

@cancan101

Using this Series:

In [38]: pd.Series([timedelta(1)])

Out[38]:
0   1 days, 00:00:00
dtype: timedelta64[ns]

This works:

In [36]: pd.Series([timedelta(1)])[0]/ np.timedelta64(1,'D')

Out[36]:
1.0

But this does not:

In [39]:

pd.Series([timedelta(1)])/ np.timedelta64(1,'D')

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-39-753422ac6b07> in <module>()
----> 1 pd.Series([timedelta(1)])/ np.timedelta64(1,'D')

/usr/lib64/python2.7/site-packages/pandas/core/series.py in wrapper(self, other, name)
    128                 elif is_timedelta_lhs and name not in ['__add__','__sub__']:
    129                     raise TypeError("can only operate on a timedeltas for "
--> 130                                     "addition and subtraction, but the operator [%s] was passed" % name)
    131 
    132                 dtype = 'timedelta64[ns]'

TypeError: can only operate on a timedeltas for addition and subtraction, but the operator [__div__] was passed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions