Skip to content

Commit e118b1d

Browse files
joy-rosieTomAugspurger
authored andcommitted
BUG: added a check for if obj is instance of type in _isna-new (#27664)
* added a check for if obj is instance of type in _isna-new
1 parent 0a7bb2a commit e118b1d

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
@@ -90,7 +90,7 @@ Indexing
9090
Missing
9191
^^^^^^^
9292

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

pandas/core/dtypes/missing.py

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ def _isna_new(obj):
133133
# hack (for now) because MI registers as ndarray
134134
elif isinstance(obj, ABCMultiIndex):
135135
raise NotImplementedError("isna is not defined for MultiIndex")
136+
elif isinstance(obj, type):
137+
return False
136138
elif isinstance(
137139
obj,
138140
(
@@ -171,6 +173,8 @@ def _isna_old(obj):
171173
# hack (for now) because MI registers as ndarray
172174
elif isinstance(obj, ABCMultiIndex):
173175
raise NotImplementedError("isna is not defined for MultiIndex")
176+
elif isinstance(obj, type):
177+
return False
174178
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass)):
175179
return _isna_ndarraylike_old(obj)
176180
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)