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

DOC: Fix doc for first_valid_index #55236

Merged
merged 7 commits into from
Sep 22, 2023

Conversation

jfadia
Copy link
Contributor

@jfadia jfadia commented Sep 22, 2023

@jfadia jfadia marked this pull request as ready for review September 22, 2023 15:27
@@ -12468,7 +12468,7 @@ def first_valid_index(self) -> Hashable | None:

Notes
-----
If all elements are non-NA/null, returns None.
Copy link
Member

Choose a reason for hiding this comment

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

Could you just remove this Notes section and demonstrate these points in the Examples section below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. One thing I was unsure of was how to handle returning None in the docs:

  • I ran it through the docstring validation script python scripts/validate_docstrings.py pandas.core.generic.NDFrame.first_valid_index
  • It was throwing errors about the output not matching the expected output because I had originally specified:
        >>> s = pd.Series()
        >>> s.first_valid_index()
        None
        >>> s.last_valid_index()
        None

I considered printing the outputs so that the outputs would match but didn't see print statements used in that way in other parts of the code so I did not keep them. Let me know if printing is the way to go here and I can make the change :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, option 1:

>>> s = pd.Series()
>>> s.first_valid_index()
>>> s.last_valid_index()

Option 2:

>>> s = pd.Series()
>>> print(s.first_valid_index())
None
>>> print(s.last_valid_index())
None

Copy link
Member

Choose a reason for hiding this comment

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

Option 2 would be fine to make it explicit in the docs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the print statements

@mroeschke mroeschke added the Docs label Sep 22, 2023
@mroeschke mroeschke merged commit 9e1096e into pandas-dev:main Sep 22, 2023
39 checks passed
@mroeschke
Copy link
Member

Thanks @jfadia

@mroeschke mroeschke added this to the 2.2 milestone Sep 22, 2023
@jfadia jfadia deleted the doc-55187-first-valid-index branch September 22, 2023 23:53
@jfadia jfadia restored the doc-55187-first-valid-index branch September 22, 2023 23:53
@jfadia jfadia deleted the doc-55187-first-valid-index branch September 22, 2023 23:53
@jfadia jfadia restored the doc-55187-first-valid-index branch September 22, 2023 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC:
2 participants