You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Period objects are inherently intervals of time, it seems like there should be a way to access Interval properties and methods. Inheritance has been suggested in passing in other issues, and seems reasonable.
As an example benefit, #9089 suggests implementing Period.duration. If Period were to inherit from Interval, this would already be implemented via the Interval.length property:
In [2]: p=pd.Period('2018Q1', freq='Q')
In [3]: p_iv=pd.Interval(p.start_time, (p+1).start_time, closed='left')
In [4]: str(p_iv)
Out[4]: '[2018-01-01, 2018-04-01)'In [5]: p_iv.lengthOut[5]: Timedelta('90 days 00:00:00')
Likewise for PeriodIndex inheriting from IntervalIndex. Would be nice to have cross compatibility between the two, e.g. IntervalIndex.overlaps(Period) or PeriodIndex.get_loc(Interval).
The text was updated successfully, but these errors were encountered:
@jreback : I recall seeing that mentioned somewhere, but can't find a corresponding issue. Do you happen to know where it is?
Also, would adding this method still be worthwhile if inheritance is implemented? Maybe if someone wanted to add a non-compatible Interval to a PeriodIndex, they'd need convert to IntervalIndex first? Not sure how common/useful that would be. Might just close this if there's no clear benefit to having this in addition to inheritance.
After some thought, I'm -1 on this. Assuming the Interval in question would have endpoints that are themselves Timestamps, this would limit the range of Period/PeriodIndex to the same bounds as Timestamp. Representing distant-past/future times is a use case that right now can only be done with Periods.
Uh oh!
There was an error while loading. Please reload this page.
Since
Period
objects are inherently intervals of time, it seems like there should be a way to accessInterval
properties and methods. Inheritance has been suggested in passing in other issues, and seems reasonable.As an example benefit, #9089 suggests implementing
Period.duration
. IfPeriod
were to inherit fromInterval
, this would already be implemented via theInterval.length
property:Likewise for
PeriodIndex
inheriting fromIntervalIndex
. Would be nice to have cross compatibility between the two, e.g.IntervalIndex.overlaps(Period)
orPeriodIndex.get_loc(Interval)
.The text was updated successfully, but these errors were encountered: