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: improve Index docstrings #50720

Merged
merged 5 commits into from
Jan 16, 2023
Merged

Conversation

abonte
Copy link
Contributor

@abonte abonte commented Jan 12, 2023

Improve docstring of the following methods:

Index.is_monotonic_increasing

output of scripts/validate_docstrings.py

################################################################################
############### Docstring (pandas.Index.is_monotonic_increasing) ###############
################################################################################

Return a boolean if the values are equal or increasing.

Returns
-------
bool

See Also
--------
Index.is_monotonic_decreasing : Check if the values are equal or decreasing.

Examples
--------
>>> pd.Index([1, 2, 3]).is_monotonic_increasing
True
>>> pd.Index([1, 2, 2]).is_monotonic_increasing
True
>>> pd.Index([1, 3, 2]).is_monotonic_increasing
False

################################################################################
################################## Validation ##################################
################################################################################

1 Errors found:
        No extended summary found

Index.is_monotonic_decreasing

output of scripts/validate_docstrings.py

################################################################################
############### Docstring (pandas.Index.is_monotonic_decreasing) ###############
################################################################################

Return a boolean if the values are equal or decreasing.

Returns
-------
bool

See Also
--------
Index.is_monotonic_increasing : Check if the values are equal or increasing.

Examples
--------
>>> pd.Index([3, 2, 1]).is_monotonic_decreasing
True
>>> pd.Index([3, 2, 2]).is_monotonic_decreasing
True
>>> pd.Index([3, 1, 2]).is_monotonic_decreasing
False

################################################################################
################################## Validation ##################################
################################################################################

1 Errors found:
        No extended summary found

Index.hasnans

output of scripts/validate_docstrings.py

################################################################################
####################### Docstring (pandas.Index.hasnans) #######################
################################################################################

Return True if there are any NaNs.

Enables various performance speedups.

Returns
-------
bool

################################################################################
################################## Validation ##################################
################################################################################

2 Errors found:
        See Also section not found
        No examples section found


Index.has_duplicates

output of scripts/validate_docstrings.py

################################################################################
################### Docstring (pandas.Index.has_duplicates)  ###################
################################################################################

Check if the Index has duplicate values.

Returns
-------
bool
    Whether or not the Index has duplicate values.

See Also
--------
Index.is_unique : Inverse method that checks if it has unique values.

Examples
--------
>>> idx = pd.Index([1, 5, 7, 7])
>>> idx.has_duplicates
True

>>> idx = pd.Index([1, 5, 7])
>>> idx.has_duplicates
False

>>> idx = pd.Index(["Watermelon", "Orange", "Apple",
...                 "Watermelon"]).astype("category")
>>> idx.has_duplicates
True

>>> idx = pd.Index(["Orange", "Apple",
...                 "Watermelon"]).astype("category")
>>> idx.has_duplicates
False

################################################################################
################################## Validation ##################################
################################################################################

1 Errors found:
        No extended summary found


Index.is_unique

output of scripts/validate_docstrings.py

################################################################################
###################### Docstring (pandas.Index.is_unique) ######################
################################################################################

Return if the index has unique values.

Returns
-------
bool

See Also
--------
Index.has_duplicates : Inverse method that checks if it has duplicate values.

Examples
--------
>>> idx = pd.Index([1, 5, 7, 7])
>>> idx.is_unique
False

>>> idx = pd.Index([1, 5, 7])
>>> idx.is_unique
True

>>> idx = pd.Index(["Watermelon", "Orange", "Apple",
...                 "Watermelon"]).astype("category")
>>> idx.is_unique
False

>>> idx = pd.Index(["Orange", "Apple",
...                 "Watermelon"]).astype("category")
>>> idx.is_unique
True

################################################################################
################################## Validation ##################################
################################################################################

1 Errors found:
        No extended summary found

@mroeschke
Copy link
Member

According to test_hasnans_uncached_for_series you will need to ensure Series.hasnans has the same docstring as Index.hasnans

@mroeschke mroeschke added the Docs label Jan 13, 2023
@abonte
Copy link
Contributor Author

abonte commented Jan 16, 2023

@mroeschke
now all checks have passed. Thank you!

@mroeschke mroeschke added this to the 2.0 milestone Jan 16, 2023
@mroeschke mroeschke merged commit d95ff3e into pandas-dev:main Jan 16, 2023
@mroeschke
Copy link
Member

Thanks @abonte

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.

2 participants