Open rwijtvliet opened 4 years ago
PS - I'd gladly make a pull request if this is considered useful. I just thought I'd ask here first.
i dont think we'd want to_timedelta specifically, but .diff
could be nice. Main sticking point is getting timedelta64 back vs array of DateOffset objects.
There's another issue about implementing .diff for numeric Index subclasses that could be addressed at the same time
Agreed that diff
would be better than to_timedelta
.
Is your feature request related to a problem?
I oftentimes find myself needing the duration of a
Period
orPeriodIndex
, which I calculate withIt seems useful and commonly used enough to be included as a standard method.
Describe the solution you'd like
Additional
.to_timedelta
method, just as there exists a.to_timestamp
method on these objects.API breaking implications
None afaics.
Describe alternatives you've considered
Use a
.duration
attribute instead, which does the conversion from timedelta to seconds((p+1).start_time - p.start_time).total_seconds()
, but that makes little sense.Additional context
Sample: