-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update the axes, shape, dim and size property docstring (Seoul) #20101
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
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 for the PR! Added some first comments
pandas/core/frame.py
Outdated
Return a list with the row axis labels and column axis labels as the | ||
only members. They are returned in that order. | ||
Return a list representing the row axis labels and column axis labels | ||
as the only members. They are returned in that order. |
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 sure this first line is a single sentence? And then you can have multiple sentences as extended summary. Please look at the docstring guideline: https://python-sprints.github.io/pandas/guide/pandas_docstring.html
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.
Sure. I will make it.
pandas/core/frame.py
Outdated
>>> df = pd.DataFrame({'col0': [1, 2, 3], 'col2': [4, 5, 6], | ||
... 'col3': [7, 8, 9]}) | ||
>>> df.shape | ||
(3, 3) |
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 an example where the number of columns and number of rows is not identical?
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.
Okay, I will make it.
pandas/core/generic.py
Outdated
... 'col3': [7, 8, 9]}) | ||
>>> df.ndim | ||
2 | ||
""" |
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 also add an example for Series? (and I think one for DataFrame is good enough)
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.
Okay, I will add.
"""Number of axes / array dimensions""" | ||
""" | ||
Return an int representing the number of axes / array dimensions. | ||
|
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 would be fine to add here a sentence saying that this is always 1 for Series and 2 for DataFrame
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.
Done.
pandas/core/generic.py
Outdated
return self._data.ndim | ||
|
||
@property | ||
def size(self): | ||
"""number of elements in the NDFrame""" | ||
""" | ||
Return a numpy.int64 representing the number of elements |
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 this also just returns an int? (and not np.int64 ?)
pandas/core/generic.py
Outdated
>>> df = pd.DataFrame({'col1': [1, 2, 3], 'col2': [4, 5, 6], | ||
... 'col3': [7, 8, 9]}) | ||
>>> df.size | ||
9 |
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.
The same here, can you also add an example for Series? And I think it would be useful to put a small sentence before the example explaining the result (so in case of dataframe number of rows times number of columns)
Codecov Report
@@ Coverage Diff @@
## master #20101 +/- ##
=========================================
Coverage ? 91.72%
=========================================
Files ? 150
Lines ? 49149
Branches ? 0
=========================================
Hits ? 45083
Misses ? 4066
Partials ? 0
Continue to review full report at Codecov.
|
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4], | ||
... 'col3': [5, 6]}) | ||
>>> df.shape | ||
(2, 3) |
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 add a See Also to ndarray.shape
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.
Done.
|
||
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]}) | ||
>>> df.ndim | ||
2 |
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.
See Also to ndarray.ndim
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.
Done.
>>> df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]}) | ||
>>> df.size | ||
4 | ||
""" |
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.
See Also to ndarray.size
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.
Done.
This change includes the following property axes, shape, ndim, size
@yeongseon Thanks a lot! |
@jorisvandenbossche No problem. |
This change includes the following property axes, shape, ndim, size
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.
Current change [1][2][3][4] occurred following error "No returns section found", "See Also section nod found".
Because this function is property. so I did not make Return and Also section.
And then axes[1] property occurred "Examples do not pass tests". I made a newline in the result to avoid flake8 error. It raises the above error.
[1] pandas.DataFrame.axes
[2] pandas.DataFrame.ndim
[3] pandas.DataFrame.size
[4] pandas.DataFrame.shape