Skip to content

Commit

Permalink
Backport PR #27664: BUG: added a check for if obj is instance of type…
Browse files Browse the repository at this point in the history
… in _isna-new (#27664) (#28041)

* added a check for if obj is instance of type in _isna-new
  • Loading branch information
TomAugspurger committed Aug 20, 2019
1 parent ca6b973 commit af049e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.1.rst
Expand Up @@ -91,7 +91,7 @@ Indexing
Missing
^^^^^^^

-
- Bug in :func:`pandas.isnull` or :func:`pandas.isna` when the input is a type e.g. `type(pandas.Series())` (:issue:`27482`)
-
-

Expand Down
4 changes: 4 additions & 0 deletions pandas/core/dtypes/missing.py
Expand Up @@ -131,6 +131,8 @@ def _isna_new(obj):
# hack (for now) because MI registers as ndarray
elif isinstance(obj, ABCMultiIndex):
raise NotImplementedError("isna is not defined for MultiIndex")
elif isinstance(obj, type):
return False
elif isinstance(
obj,
(
Expand Down Expand Up @@ -169,6 +171,8 @@ def _isna_old(obj):
# hack (for now) because MI registers as ndarray
elif isinstance(obj, ABCMultiIndex):
raise NotImplementedError("isna is not defined for MultiIndex")
elif isinstance(obj, type):
return False
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass)):
return _isna_ndarraylike_old(obj)
elif isinstance(obj, ABCGeneric):
Expand Down
4 changes: 4 additions & 0 deletions pandas/tests/dtypes/test_missing.py
Expand Up @@ -86,6 +86,10 @@ def test_isna_isnull(self, isna_f):
assert not isna_f(np.inf)
assert not isna_f(-np.inf)

# type
assert not isna_f(type(pd.Series()))
assert not isna_f(type(pd.DataFrame()))

# series
for s in [
tm.makeFloatSeries(),
Expand Down

0 comments on commit af049e3

Please sign in to comment.