Skip to content

ERR: MultiIndex searchsorted #14990

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

Closed
wants to merge 3 commits into from

Conversation

ShaharBental
Copy link

@jreback
Copy link
Contributor

jreback commented Dec 26, 2016

@ShaharBental on the issue I indicated that this should simply raise a NotImplementedError (or maybe a ValueError). I don't think this is actually useful as the indexing methods on a MultiIndex already do this (they use searchsorted internally in certain cases).

@jreback jreback added Error Reporting Incorrect or improved errors from pandas MultiIndex labels Dec 26, 2016
@jreback jreback changed the title Issue14833 ERR: MultiIndex searchsorted Dec 26, 2016
@codecov-io
Copy link

Current coverage is 84.66% (diff: 100%)

Merging #14990 into master will increase coverage by <.01%

@@             master     #14990   diff @@
==========================================
  Files           144        144          
  Lines         51056      51072    +16   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43225      43241    +16   
  Misses         7831       7831          
  Partials          0          0          

Powered by Codecov. Last update aba7d25...d22e816

@ShaharBental
Copy link
Author

@jreback Sorry, changed it to simply raise a NotImplementedError
I think it should be NotImplementedError and not ValueError, as the problem lies with the type of self and not any specific value.

@@ -1470,6 +1470,9 @@ def get_indexer(self, target, method=None, limit=None, tolerance=None):

return _ensure_platform_int(indexer)

def searchsorted(self, value, side='left', sorter=None):
raise NotImplementedError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a helpful message that explains one should use multi-index indexing here.

# Test if MultiIndex searchsorted raises the NotImplementedException
df_mi = pd.MultiIndex([[0], ["a"]], [[0], [0]])
with self.assertRaises(Exception) as context:
df_mi.searchsorted((1, "b"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with self.assertRaises(NotImplementedError):
   ...

is enough

@jreback
Copy link
Contributor

jreback commented Dec 26, 2016

pls add a note in other api changes in 0.20.0

@jreback
Copy link
Contributor

jreback commented Feb 27, 2017

closing as stale. please ping if you'd like to continue.

@jreback jreback closed this Feb 27, 2017
@jreback jreback added this to the No action milestone Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas MultiIndex
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiarray searchsorted fails
3 participants