-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG: TimedeltaIndex.intersection #22114
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
BUG: TimedeltaIndex.intersection #22114
Conversation
62d9e3e to 5af3c53 Compare
jreback left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a whatsnew note in bug fixes / timedeltas
| """ alias for is_monotonic_increasing (deprecated) """ | ||
| return self.is_monotonic_increasing | ||
| | ||
| @property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we actually using this? (it seems you in-lined it below), I actually prefer that to making a new method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names are similar, but I'm calling this function twice in the intersection function to help me deal with the boolean logic (already hard for me to follow, even with this addition). I can remove this, and put this inline if you really want it that way.
pandas/core/indexes/datetimelike.py Outdated
| end = right[-1] | ||
| | ||
| if end > start: | ||
| return Index() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this not []?
pandas/core/indexes/datetimelike.py Outdated
| start = right[0] | ||
| | ||
| if end < start: | ||
| return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth to consolidate these into 1 routine? as you can call with the ascending arg
pandas/core/indexes/datetimelike.py Outdated
| result.offset = frequencies.to_offset(result.inferred_freq) | ||
| return result | ||
| | ||
| # handle intersecting things like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a tiny bit more of expl
pandas/tseries/offsets.py Outdated
| return wrapper | ||
| | ||
| | ||
| def apply_index_wraps(func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been awhile. I don't remember writing this code. I'll guess an artifact of my rebase.
| Having come back at this, I'm struggling with how to deal with all the edge cases that need to be accounted for before trying to apply this quick method of intersecting, and this is making me question whether or not to even include it. I'm having a hard time describing it clearly, but hopefully this is making sense. If not, I can commit my broken code so you all can see what I'm talking about. |
| A possibility to at least solve the bug would be to fall back to the Basically similar like pandas/pandas/core/indexes/datetimes.py Lines 1006 to 1015 in 59cfd8c
Will not be the most performant option, but at least could fix the bug |
| @jorisvandenbossche I thought I had been doing that, but it seems my check was backwards for that case :/. Correcting that appears to solve the issues. Thanks! |
5af3c53 to 808ce4e Compare | Hello @kirkhansen! Thanks for updating the PR.
Comment last updated on December 12, 2018 at 21:29 Hours UTC |
808ce4e to 5703681 Compare Codecov Report
@@ Coverage Diff @@ ## master #22114 +/- ## ========================================== + Coverage 92.21% 92.22% +<.01% ========================================== Files 162 162 Lines 51768 51761 -7 ========================================== - Hits 47739 47734 -5 + Misses 4029 4027 -2
Continue to review full report at Codecov.
|
| if you can merge master |
shallow_copy appears to no longer accept tz...
let's see what's broken now.
16965c5 to 2f5513c Compare | You'll need to run |
| first = getattr(first, 'freq', None) | ||
| second = getattr(second, 'freq', None) | ||
| are_offsets_equal = True | ||
| if first is None or second is None or first != second: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just return this statement; no need for the intermediate variable
| df2 = tm.makeTimeDataFrame().rename(columns=lambda x: "%s_2" % x) | ||
| df1.iloc[1, df1.columns.get_indexer(['A', 'B'])] = np.nan | ||
| df = concat([df1, df2], axis=1) | ||
| print(df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This print should be removed.
| """ | ||
| Speedy intersection that works only if certain assumptions are met. | ||
| See intersection for details. | ||
| Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give a bit more color to Parameters and Returns
| Closing as stale ping if you'd like to continue |
git diff upstream/master -u -- "*.py" | flake8 --diff