Skip to content

Commit 7c1d7b3

Browse files
authored
REF: DataFrame.isna internals access (#33124)
1 parent 93305d8 commit 7c1d7b3

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pandas/core/dtypes/missing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _isna_new(obj):
152152
):
153153
return _isna_ndarraylike(obj)
154154
elif isinstance(obj, ABCDataFrame):
155-
return obj._constructor(obj._data.isna(func=isna))
155+
return obj.isna()
156156
elif isinstance(obj, list):
157157
return _isna_ndarraylike(np.asarray(obj, dtype=object))
158158
elif hasattr(obj, "__array__"):
@@ -183,7 +183,7 @@ def _isna_old(obj):
183183
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass, ABCExtensionArray)):
184184
return _isna_ndarraylike_old(obj)
185185
elif isinstance(obj, ABCDataFrame):
186-
return obj._constructor(obj._data.isna(func=_isna_old))
186+
return obj.isna()
187187
elif isinstance(obj, list):
188188
return _isna_ndarraylike_old(np.asarray(obj, dtype=object))
189189
elif hasattr(obj, "__array__"):

pandas/core/frame.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,19 +4478,20 @@ def _maybe_casted_values(index, labels=None):
44784478

44794479
@Appender(_shared_docs["isna"] % _shared_doc_kwargs)
44804480
def isna(self) -> "DataFrame":
4481-
return super().isna()
4481+
result = self._constructor(self._data.isna(func=isna))
4482+
return result.__finalize__(self)
44824483

44834484
@Appender(_shared_docs["isna"] % _shared_doc_kwargs)
44844485
def isnull(self) -> "DataFrame":
4485-
return super().isnull()
4486+
return self.isna()
44864487

44874488
@Appender(_shared_docs["notna"] % _shared_doc_kwargs)
44884489
def notna(self) -> "DataFrame":
4489-
return super().notna()
4490+
return ~self.isna()
44904491

44914492
@Appender(_shared_docs["notna"] % _shared_doc_kwargs)
44924493
def notnull(self) -> "DataFrame":
4493-
return super().notnull()
4494+
return ~self.isna()
44944495

44954496
def dropna(self, axis=0, how="any", thresh=None, subset=None, inplace=False):
44964497
"""

0 commit comments

Comments
 (0)