Skip to content

ENH: allow timedelta64 to be divided by integers #4521

Closed
@jreback

Description

@jreback

I belive numpy < 1.7 is very problematic with this, but 1.7 is ok

http://stackoverflow.com/questions/18142144/dividing-a-series-containing-datetime-by-a-series-containing-an-integer-in-panda

import pandas as pd
from pandas import Series

startdate = Series(pd.date_range('2013-01-01', '2013-01-03'))
enddate = Series(pd.date_range('2013-03-01', '2013-03-03'))

s1 = enddate - startdate
s2 = Series([2, 3, 4])

event_freq = Series(s1.values / s2)
Here are the Series:
>>> s1
0   59 days, 00:00:00
1   59 days, 00:00:00
2   59 days, 00:00:00
dtype: timedelta64[ns]

>>> s2
0    2
1    3
2    4
dtype: int64

>>> event_freq
0   29 days, 12:00:00
1   19 days, 16:00:00
2   14 days, 18:00:00
dtype: timedelta64[ns]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions