-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC add example of Series.index #51842
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
Conversation
Added the example section.
Hi @DeaMariaLeon , could you please help me in this issue ? The error says ---> Error: None:None:GL01:pandas.Series.index:Docstring text (summary) should start in the line immediately after the opening quotes (not in the same line, or leaving a blank line in between). But I saw in the series.py file ; every summary is written after leaving a blank line. And this one too https://github.com/pandas-dev/pandas/actions/runs/4365774703/jobs/7634865667 |
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.
hi @ggold7046
before fixing the validation errors - did you try building this docstring locally? could you post a screenshot of how it looks please?
I used gitpod for development https://pandas.pydata.org/docs/dev/development/contributing_gitpod.html and write the docstring and tested with python scripts/validate_docstrings.py pandas.Series.index . As most of the test were passed and there was no "no example section found" error, I pulled a request. |
Updated the docstring.
Updated the docstring.
New update.
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 @ggold7046 for the contribution, added some comments. As Marco says, you'll need to build the documentation locally. You have instructions on the contrubuting documentation.
pandas/core/series.py
Outdated
axis=0, doc="The index (axis labels) of the 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.
Can you make this a single text, not concatenating in this way please?
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.
Sorry, but didn't understand. You mean like this ?
axis=0, doc="The index (axis labels) of the Series." """ A one-dimensional ndarray with hashable type axis labels. """
or this
axis=0, doc="The index (axis labels) of the Series."
""" A one-dimensional ndarray with hashable type axis labels. """
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.
Could you please use triple backticks to format code blocks? Without it, your question is really hard to read.
What @datapythonista means is that you have two strings here that will be concatenated:
a = (
"The index [...]"
"""
A one-dimensional [...]
"""
)
print(a)
The index [...]
A one-dimensional [...]
Since you already have a multiline string (triple quotes), you can just merge the two:
b = """\
The index [...]
A one-dimensional [...]
"""
print(b)
The index [...]
A one-dimensional [...]
pandas/core/series.py
Outdated
**Use the Series.index attribute to set the index label for | ||
the given Series object.** | ||
|
||
>>> s = pd.Series(['Kolkata', 'Chicago', 'Toronto', 'Lisbon']) |
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 example is not very realistic and confusing with the City 1
, City 2
labels. Maybe something like using the city as index and then making the value a feature like population, average temperature... would make more sense.
Also, since here you're just showing the .index
accessor, better create the index with Series(..., index=...)
and simply show that your_series.index
returns the index.
pandas/core/series.py
Outdated
Pandas Series.index attribute is used to get or set the index labels | ||
of the given Series object.The object supports both | ||
integer- and label-based indexing and provides a host of methods for | ||
performing operations involving the index. | ||
The labels need not be unique but must be of the hashable type. |
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 makes more sense to link to the indexing user guide that try to explain what's indexing in a single paragraph here.
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.
So, I have to add a see also section and mention this link ? https://pandas.pydata.org/docs/reference/api/pandas.Index.html
Online doc preview for this PR is here: https://pandas.pydata.org/preview/51842/docs/reference/api/pandas.Series.index.html#pandas.Series.index |
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.
There are currently three CI jobs failing:
- https://github.com/pandas-dev/pandas/actions/runs/4584805993/jobs/8096531909?pr=51842#step:4:274
- https://github.com/pandas-dev/pandas/actions/runs/4584805993/jobs/8096531828?pr=51842#step:8:12
- https://github.com/pandas-dev/pandas/actions/runs/4584805987/jobs/8096531417?pr=51842#step:6:68
They are all related to the formatting of the docstring you wrote. Let's go through them one by one inline below.
Note that all these things are very project specific. Every project defines their own style and one has to abide by that.
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
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.
You have more trailing whitespace.
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
Co-authored-by: Philip Meier <[email protected]>
This is the error I'm getting while running the Error installing pre-commit(pandas-dev) gitpod > /workspace/pandas $ pre-commit install An unexpected error has occurred: PermissionError: [Errno 13] Permission denied: '/home/gitpod/.cache/pre-commit' Traceback (most recent call last): File "/home/gitpod/mambaforge3/envs/pandas-dev/lib/python3.8/site-packages/pre_commit/error_handler.py", line 73, in error_handler yield File "/home/gitpod/mambaforge3/envs/pandas-dev/lib/python3.8/site-packages/pre_commit/main.py", line 340, in main store = Store() File "/home/gitpod/mambaforge3/envs/pandas-dev/lib/python3.8/site-packages/pre_commit/store.py", line 51, in __init__ os.makedirs(self.directory, exist_ok=True) File "/home/gitpod/mambaforge3/envs/pandas-dev/lib/python3.8/os.py", line 223, in makedirs mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/home/gitpod/.cache/pre-commit' During handling of the above exception, another exception occurred: Traceback (most recent call last): Though when I do |
@ggold7046 Please make it a habit to wrap terminal output in triple backticks to get proper formatting. The traceback is painful to read the way you posted it. The error you are facing has little to do with For this PR though, you don't need
|
Hi @pmeier , both the |
Website preview of this PR available at: https://pandas.pydata.org/preview/51842/ |
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.
Awesome @ggold7046. Docstring looks good formatting wise and CI is happy as well. Now someone from the pandas
team needs to review the content.
Hi @MarcoGorelli , @datapythonista, @mroeschke could you have a review on this please ? I hope this time this PR gets merged. |
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 for working on this - got a minor comment, but this looks like it's close
can you also remove this line
Line 88 in 8c7b8a4
pandas.Series.index \ |
please?
pandas/core/series.py
Outdated
doc=""" | ||
The index (axis labels) of the Series. | ||
|
||
Get the index (row labels) of the 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'm not sure what this sentence adds - why not move the paragraph starting with
The index of a Series is used to label and identify each element of the
to here?
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.
to here?
I did not get it. Could you please tell me where to move ?
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.
where I left the comment. i.e. instead of this "Get the index (row labels) of the Series." paragraph
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.
Hi @MarcoGorelli , I tried to move that paragraph The index of a Series is used to label and identify each element of the
to the first line replacing Get the index (row labels) of the Series.
, but it failed the CI. In the pandas documentation it is said that the first summary line should be a single meaning full line. And then an extending summary. So can we keep that single line as it is and can I revert back to the old commit ?
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.
Not sure what you mean here @ggold7046. The summary, i.e.
The index (axis labels) of the Series.
is a single line. The CI fails because you again included trailing white space in the blank line.
Hi @MarcoGorelli , I'm unable to edit this file in github page. The edit button is greyed out. |
You should edit this file inside your PR. So judging from the comments above, inside the GitPod environment. |
DOC add example of Series.index #51842
@MarcoGorelli, @datapythonista, I have updated both the files. Could you please take a look and tell me if everything is fine ? |
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.
Well done, thanks for sticking with this for so long
I'll leave open a bit in case Marc has other comments, and if not then we can merge
Hi @datapythonista , could you please have a look at this PR so that it could be merged ? |
Thanks @ggold7046 and the rest, very nice work. |
Hello @datapythonista , @MarcoGorelli thank for your time and support. And many many thanks for @pmeier for sticking with me for so long on this. |
Added the example section.
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.