-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DISC: Period.__le__ #17692
Comments
Another point of reference is pandas/pandas/_libs/interval.pyx Lines 91 to 94 in d3be81a
So if we care about ordering periods with different frequencies, this would be a reasonable choice. On the other hand, if we don't have use cases for this, from a usability perspective it is probably better to stick with refusing to order potentially overlapping periods.
So |
yeah in an ideal work we would actually use an Interval to back a Period. Yes we should clarify the semantics here. |
Yah, it's sub-optimal. The question becomes if we want to implement the unambiguous cases and continue raising for ambiguous ones vs leave existing behavior. Even for cases with overlap
From #17112,
In py2 raises |
Doesn't look like there's a lot of enthusiasm for this. One more shot with a less ambitious fix: just define |
Lack of consensus, closing. |
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 theper1.end_time < per2.start_time
, then it should be the case thatper1 < per2
unambiguously. This intuition also extends todatetime
andTimestamp
objects that do not lie betweenper.start_time
andper.end_time
.For cases with overlap there are a couple of reasonable approaches. My preferred approach is lexicographic: first compare
per1.start_time
withper2.start_time
. If they are equal, then compare theend_time
s. Then we treatdatetime
andTimestamp
objects as analogous to zero-duration periods.Thoughts?
The text was updated successfully, but these errors were encountered: