File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ Performance Improvements
2929 is likewise much faster (:issue:`21369`)
3030- Improved performance of membership checks in :class:`Categorical`
3131 (i.e. ``x in categorical``-style checks are much faster) (:issue:`21369`)
32-
3332-
3433
3534Documentation Changes
Original file line number Diff line number Diff line change @@ -1849,11 +1849,35 @@ def __iter__(self):
18491849
18501850 @staticmethod
18511851 def _contains (key , categories , container ):
1852- """Returns True if `key` is in `categories` and the
1853- location of `key` in `categories` is in `container `.
1852+ """
1853+ Helper for membership check for ``key` `.
18541854
1855- This is a helper method used in :method:`Categorical.__contains__`
1855+ This helper method is used in :method:`Categorical.__contains__`
18561856 and in :class:`CategoricalIndex.__contains__`.
1857+
1858+ Returns True if ``key`` is in ``categories`` and the
1859+ location of ``key`` in ``categories`` is in ``container``.
1860+
1861+ Parameters
1862+ ----------
1863+ key : a hashable object
1864+ The key to check membership for.
1865+ categories : Sequence
1866+ The possible values for ``key``. The location for ``key``
1867+ in ``categories`` is also its value in ``container``
1868+ container : Container (e.g. list-like or mapping)
1869+ The container to check for membership in.
1870+
1871+ Returns
1872+ -------
1873+ is_in : bool
1874+ True if ``key`` is in ``categories`` and location of
1875+ ``key`` in ``categories`` is in ``container``, else False.
1876+
1877+ Notes
1878+ -----
1879+ This method does not check for Nan values. Do that separately
1880+ before calling this method.
18571881 """
18581882
18591883 # is key in categories? Then get its location in categories.
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ def test_isin_empty(empty):
7272
7373
7474def test_contains ():
75-
75+ # GH21508
7676 c = pd .Categorical (list ('aabbca' ), categories = list ('cab' ))
7777
7878 assert 'b' in c
@@ -84,7 +84,6 @@ def test_contains():
8484 assert 1 not in c
8585
8686 c = pd .Categorical (list ('aabbca' ) + [np .nan ], categories = list ('cab' ))
87-
8887 assert np .nan in c
8988
9089
You can’t perform that action at this time.
0 commit comments