Skip to content

Commit 5b6e12b

Browse files
committed
fix categoricals
1 parent d8bdb2e commit 5b6e12b

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

doc/source/whatsnew/v1.2.0.rst

-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ Deprecations
484484
- Deprecated :meth:`Index.asi8` for :class:`Index` subclasses other than :class:`.DatetimeIndex`, :class:`.TimedeltaIndex`, and :class:`PeriodIndex` (:issue:`37877`)
485485
- The ``inplace`` parameter of :meth:`Categorical.remove_unused_categories` is deprecated and will be removed in a future version (:issue:`37643`)
486486
- The ``null_counts`` parameter of :meth:`DataFrame.info` is deprecated and replaced by ``show_counts``. It will be removed in a future version (:issue:`37999`)
487-
- Deprecated membership checks for nan-likes in :class:`Categorical`. In the future the membership check will only return True if the nan-like is ``nan`` or of the same dtype as the underlying categories (:issue:`37867`)
488487

489488
.. ---------------------------------------------------------------------------
490489

pandas/core/arrays/categorical.py

-7
Original file line numberDiff line numberDiff line change
@@ -1749,13 +1749,6 @@ def __contains__(self, key) -> bool:
17491749

17501750
# if key is a NaN, check if any NaN is in self.
17511751
if is_valid_nat_for_dtype(key, self.categories.dtype):
1752-
if key is not self.dtype.na_value and not isinstance(key, self.dtype.type):
1753-
warn(
1754-
f"Membership check with {key} will return False in the future. "
1755-
f"Consider using {self.dtype.na_value} instead",
1756-
FutureWarning,
1757-
stacklevel=2,
1758-
)
17591752
return self.isna().any()
17601753

17611754
return contains(self, key, container=self._codes)

pandas/tests/extension/test_categorical.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ def test_contains(self, data, data_missing):
109109
if na_value_type is na_value:
110110
continue
111111

112-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
113-
assert na_value_type not in data
114-
assert na_value_type in data_missing
112+
assert na_value_type not in data
113+
assert na_value_type in data_missing
115114

116115

117116
class TestConstructors(base.BaseConstructorsTests):

0 commit comments

Comments
 (0)