Skip to content
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

ENH: set __module__ on isna and notna #60271

Merged
merged 18 commits into from
Nov 12, 2024

Conversation

SiemBerhane
Copy link
Contributor

@chanshing
Copy link
Contributor

pd.notna is top-level too and is defined in missing.py, so maybe could be included in this PR

def notna(obj: object) -> bool | npt.NDArray[np.bool_] | NDFrame:

@simonjayhawkins simonjayhawkins added this to the 3.0 milestone Nov 9, 2024
@simonjayhawkins simonjayhawkins added Output-Formatting __repr__ of pandas objects, to_string Sprints Sprint Pull Requests labels Nov 9, 2024
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @SiemBerhane

@SiemBerhane
Copy link
Contributor Author

Thanks @SiemBerhane

Glad it finally works. Thanks for your help!

@jorisvandenbossche jorisvandenbossche changed the title decorate isna with @set_module('pandas') ENH: set __module__ on isna and notna Nov 11, 2024
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

Because of merging some of the related PRs, there is now a merge conflict in the tests file. Could you merge the latest main to resolve that conflict? (and let us know if you need any help with that)

@simonjayhawkins
Copy link
Member

@jorisvandenbossche

isnull and notnull are aliases to isna and notna respectively that are also defined in pandas/core/dtypes/missing.py

now the documentation for isnull is the same as isna (because it's just an alias to isna).

should the docs additionally mention that is an alias? are isnull and notnull recommended uses?

in IPython the repr now for pd.isnull is <function pandas.isna(obj: 'object') -> 'bool | npt.NDArray[np.bool_] | NDFrame'>. While we're improving the output formatting is there any value in making this show <function pandas.isnull.... instead?

would we also want an assert in the tests for pd.isnull and pd.notnull too?

@simonjayhawkins simonjayhawkins merged commit 5f23ace into pandas-dev:main Nov 12, 2024
28 of 34 checks passed
@jorisvandenbossche
Copy link
Member

isnull and notnull are aliases to isna and notna respectively that are also defined in pandas/core/dtypes/missing.py

I think for those aliases it is fine that the repr points to the isna/notna instead (I mean, I wouldn't do specific effort to fix that, although addressing the docstring might also address this).

Ideally those docstrings of isnull/notnull should mention they are aliases, though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Sprints Sprint Pull Requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants