diff --git a/pandas/core/dtypes/missing.py b/pandas/core/dtypes/missing.py index e80e6f370f46e..26de1c60f5feb 100644 --- a/pandas/core/dtypes/missing.py +++ b/pandas/core/dtypes/missing.py @@ -153,7 +153,8 @@ def _isna(obj, inf_as_na: bool = False): return libmissing.checknull(obj) # hack (for now) because MI registers as ndarray elif isinstance(obj, ABCMultiIndex): - raise NotImplementedError("isna is not defined for MultiIndex") + # If there is within a level an NA, the entire label is considered NA + return obj.to_frame().isna().any(axis="columns").values elif isinstance(obj, type): return False elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndex, ABCExtensionArray)): diff --git a/pandas/tests/indexes/common.py b/pandas/tests/indexes/common.py index 6874db66a8597..acd4726c4d8a9 100644 --- a/pandas/tests/indexes/common.py +++ b/pandas/tests/indexes/common.py @@ -625,11 +625,6 @@ def test_nulls(self, index): # as these are adequately tested for function elsewhere if len(index) == 0: tm.assert_numpy_array_equal(index.isna(), np.array([], dtype=bool)) - elif isinstance(index, MultiIndex): - idx = index.copy() - msg = "isna is not defined for MultiIndex" - with pytest.raises(NotImplementedError, match=msg): - idx.isna() elif not index.hasnans: tm.assert_numpy_array_equal(index.isna(), np.zeros(len(index), dtype=bool)) tm.assert_numpy_array_equal(index.notna(), np.ones(len(index), dtype=bool)) diff --git a/pandas/tests/indexes/multi/test_missing.py b/pandas/tests/indexes/multi/test_missing.py index cd95802ac29c9..6d05f965ba9bd 100644 --- a/pandas/tests/indexes/multi/test_missing.py +++ b/pandas/tests/indexes/multi/test_missing.py @@ -56,10 +56,7 @@ def test_dropna(): def test_nulls(idx): # this is really a smoke test for the methods # as these are adequately tested for function elsewhere - - msg = "isna is not defined for MultiIndex" - with pytest.raises(NotImplementedError, match=msg): - idx.isna() + idx.isna() @pytest.mark.xfail(reason="isna is not defined for MultiIndex")