Skip to content

REF: DataFrame.isna internals access #33124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _isna_new(obj):
):
return _isna_ndarraylike(obj)
elif isinstance(obj, ABCDataFrame):
return obj._constructor(obj._data.isna(func=isna))
return obj.isna()
elif isinstance(obj, list):
return _isna_ndarraylike(np.asarray(obj, dtype=object))
elif hasattr(obj, "__array__"):
Expand Down Expand Up @@ -183,7 +183,7 @@ def _isna_old(obj):
elif isinstance(obj, (ABCSeries, np.ndarray, ABCIndexClass, ABCExtensionArray)):
return _isna_ndarraylike_old(obj)
elif isinstance(obj, ABCDataFrame):
return obj._constructor(obj._data.isna(func=_isna_old))
return obj.isna()
elif isinstance(obj, list):
return _isna_ndarraylike_old(np.asarray(obj, dtype=object))
elif hasattr(obj, "__array__"):
Expand Down
9 changes: 5 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4478,19 +4478,20 @@ def _maybe_casted_values(index, labels=None):

@Appender(_shared_docs["isna"] % _shared_doc_kwargs)
def isna(self) -> "DataFrame":
return super().isna()
result = self._constructor(self._data.isna(func=isna))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be isna or isna_old depending on the settings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and since that is handled in the isna function, I am not fully sure it will be easier to do it here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be isna or isna_old depending on the settings?

No, the _isna/_isna_old is reflected in isna

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed that. So it's basically calling that recursively on its parts. OK!

return result.__finalize__(self)

@Appender(_shared_docs["isna"] % _shared_doc_kwargs)
def isnull(self) -> "DataFrame":
return super().isnull()
return self.isna()

@Appender(_shared_docs["notna"] % _shared_doc_kwargs)
def notna(self) -> "DataFrame":
return super().notna()
return ~self.isna()

@Appender(_shared_docs["notna"] % _shared_doc_kwargs)
def notnull(self) -> "DataFrame":
return super().notnull()
return ~self.isna()

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