-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
There are a bunch of issues outstanding that relate to Period
ops and comparison. AFAICT making a decision about the comparison issue will snowball into resolving (some of) the ops issues.
#5202 ENH: Period ops NaT & timedelta ops
#10798 Date / Datetime in Period Index
#6779 Adding Period and Offset not implemented
#13077 ENH/API: Decide what to return Period - Period subtraction
#17112 MultiIndex - Comparison with Mixed Frequencies (and other FUBAR)
Right now two Period objects are comparable iff they equal freq
attributes. AFAICT this is to avoid guessing in cases where the "correct" answer is ambiguous. But there are some other cases with an obviously correct answer. Namely, if the per1.end_time < per2.start_time
, then it should be the case that per1 < per2
unambiguously. This intuition also extends to datetime
and Timestamp
objects that do not lie between per.start_time
and per.end_time
.
For cases with overlap there are a couple of reasonable approaches. My preferred approach is lexicographic: first compare per1.start_time
with per2.start_time
. If they are equal, then compare the end_time
s. Then we treat datetime
and Timestamp
objects as analogous to zero-duration periods.
Thoughts?