Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


def reindex(self, target, method=None, level=None, limit=None,
tolerance=None):
"""
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,13 @@ def test_iloc_mi(self):

assert_frame_equal(result, expected)

def test_searchsorted(self):
# GH 14833
# 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

self.assertTrue(context.exception,NotImplementedError())

if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
Expand Down