-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
implement searchsorted for multindex (bug #14833) #23210
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
Conversation
Hello @btel! Thanks for updating the PR.
Comment last updated on October 17, 2018 at 19:42 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #23210 +/- ##
==========================================
+ Coverage 92.19% 92.19% +<.01%
==========================================
Files 169 169
Lines 50954 50961 +7
==========================================
+ Hits 46975 46982 +7
Misses 3979 3979
Continue to review full report at Codecov.
|
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.
I am not convinced of the utility of using searchsorted here, what are you going to do with this?
@@ -2899,6 +2900,13 @@ def isin(self, values, level=None): | |||
else: | |||
return np.lib.arraysetops.in1d(labs, sought_labels) | |||
|
|||
def searchsorted(self, arr): | |||
dtype = [l.dtype.descr for l in self.levels] |
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 will be much more performant to do this level by level (as you iterate over the key). which btw must be fully specified. needs a doc-string and error checking.
@@ -346,3 +346,8 @@ def test_get_indexer_categorical_time(): | |||
Categorical(date_range("2012-01-01", periods=3, freq='H'))]) | |||
result = midx.get_indexer(midx) | |||
tm.assert_numpy_array_equal(result, np.arange(9, dtype=np.intp)) | |||
|
|||
|
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.
needs error checking, and a full-on test where the element is there (to be honest you should simply do a .get_loc()
) first to find it then if not found do the searchsorted. You must also assert that the index is lexsorted as well.
cc @toobaz |
Can you merge master and address comments? |
closing as stale, but ping to reopen if can continue |
git diff upstream/master -u -- "*.py" | flake8 --diff
Proof-of-concept to fix #14833.
This works: