Skip to content

FIX: Add Categorical.searchsorted stub #8421

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

Merged
merged 1 commit into from
Sep 29, 2014
Merged
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/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ def T(self):
def nbytes(self):
return self._codes.nbytes + self._categories.values.nbytes

def searchsorted(self, v, side='left', sorter=None):
raise NotImplementedError("See https://github.com/pydata/pandas/issues/8420")

def isnull(self):
"""
Detect missing values
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,15 @@ def test_nbytes(self):
exp = cat._codes.nbytes + cat._categories.values.nbytes
self.assertEqual(cat.nbytes, exp)

def test_searchsorted(self):

# See https://github.com/pydata/pandas/issues/8420
# TODO: implement me...
cat = pd.Categorical([1,2,3])
def f():
cat.searchsorted(3)
self.assertRaises(NotImplementedError, f)

def test_deprecated_labels(self):
# TODO: labels is deprecated and should be removed in 0.18 or 2017, whatever is earlier
cat = pd.Categorical([1,2,3, np.nan], categories=[1,2,3])
Expand Down