Skip to content

Commit af049e3

Browse files
Backport PR #27664: BUG: added a check for if obj is instance of type in _isna-new (#27664) (#28041)
* added a check for if obj is instance of type in _isna-new
1 parent ca6b973 commit af049e3

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/source/whatsnew/v0.25.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Indexing
9191
Missing
9292
^^^^^^^
9393

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

pandas/core/dtypes/missing.py

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def _isna_new(obj):
131131
# hack (for now) because MI registers as ndarray
132132
elif isinstance(obj, ABCMultiIndex):
133133
raise NotImplementedError("isna is not defined for MultiIndex")
134+
elif isinstance(obj, type):
135+
return False
134136
elif isinstance(
135137
obj,
136138
(
@@ -169,6 +171,8 @@ def _isna_old(obj):
169171
# hack (for now) because MI registers as ndarray
170172
elif isinstance(obj, ABCMultiIndex):
171173
raise NotImplementedError("isna is not defined for MultiIndex")
174+
elif isinstance(obj, type):
175+
return False
172176
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass)):
173177
return _isna_ndarraylike_old(obj)
174178
elif isinstance(obj, ABCGeneric):

pandas/tests/dtypes/test_missing.py

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def test_isna_isnull(self, isna_f):
8686
assert not isna_f(np.inf)
8787
assert not isna_f(-np.inf)
8888

89+
# type
90+
assert not isna_f(type(pd.Series()))
91+
assert not isna_f(type(pd.DataFrame()))
92+
8993
# series
9094
for s in [
9195
tm.makeFloatSeries(),

0 commit comments

Comments
 (0)