-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.Index.is_categorical docstring #20167
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: update the pandas.Index.is_categorical docstring #20167
Conversation
What's the output of of the vlaidate_docstrings script? |
pandas/core/indexes/base.py
Outdated
""" | ||
Check if the index type is categorical. | ||
|
||
The given object must be a pandas dataframe or pandas Series. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataframe -> DataFrame
pandas/core/indexes/base.py
Outdated
The given object must be a pandas dataframe or pandas Series. | ||
|
||
Returns | ||
---------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the same length as "Returns"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things if you could update. looks good otherwise!
pandas/core/indexes/base.py
Outdated
|
||
Examples | ||
-------- | ||
>>> s = pd.Series(["Watermelon","Orange","Apple", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space after the commas
pandas/core/indexes/base.py
Outdated
-------- | ||
>>> s = pd.Series(["Watermelon","Orange","Apple", | ||
... "Watermelon"]).astype('category') | ||
>>> df = pd.DataFrame({'Weight (grams)':[2000,230,160,1300]}, index=s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spcae after the colon. Space after commas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comments ^^ !! We have already changed it.
pandas/core/indexes/base.py
Outdated
>>> df.index.is_categorical() | ||
True | ||
|
||
>>> df = pd.Series(["Peter","Adam","Elisabeth","Margareth"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call the ser =
since it's a series :)
pandas/core/indexes/base.py
Outdated
|
||
Examples | ||
-------- | ||
>>> s = pd.Series(["Watermelon","Orange","Apple", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after ","
pandas/core/indexes/base.py
Outdated
-------- | ||
>>> s = pd.Series(["Watermelon","Orange","Apple", | ||
... "Watermelon"]).astype('category') | ||
>>> df = pd.DataFrame({'Weight (grams)':[2000,230,160,1300]}, index=s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after ","
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, we appreciate your comments! We have already changed it :)
pandas/core/indexes/base.py
Outdated
""" | ||
Check if the Index type is categorical. | ||
|
||
The given object must be a pandas DataFrame or pandas Series. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only applies to a Series or an Index, IOW it must be 1D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jreback ! I have changed the exended summary. Is it better now?
pandas/core/indexes/base.py
Outdated
-------- | ||
>>> s = pd.Series(["Watermelon", "Orange", "Apple", | ||
... "Watermelon"]).astype('category') | ||
>>> df = pd.DataFrame({'Weight (grams)': [2000, 230, 160, 1300]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't create a DataFrame here just to use its index, just use the series above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, Thank you! I have changed the examples.
Codecov Report
@@ Coverage Diff @@
## master #20167 +/- ##
=========================================
Coverage ? 91.7%
=========================================
Files ? 150
Lines ? 49152
Branches ? 0
=========================================
Hits ? 45074
Misses ? 4078
Partials ? 0
Continue to review full report at Codecov.
|
pandas/core/indexes/base.py
Outdated
""" | ||
Check if the Index type is categorical. | ||
|
||
The given object must be a pandas DataFrame index or a pandas Series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's best to just remove this. There isn't really an object being passed, it's just an attribute on Index classes.
Removed Extended summary
Just pushed a commit removing the extended sumary. Added a See Also for CategoricalIndex. |
pandas/core/indexes/base.py
Outdated
|
||
See Also | ||
-------- | ||
CategoricalIndex : Index for categorical data. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the See Also!
pandas/core/indexes/base.py
Outdated
|
||
The given object must be a pandas DataFrame index or a pandas Series | ||
index. | ||
Check if the Index holds categorical data. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! Thank you :)
…ni-docstring_Index.is_categorical
Thank you for working on this. |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.
We think that See Also is not necessary for this function.