-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the DataFrame.pivot docstring #20250
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! Added a few comments
Can you add a "Raises" section? As I think this is commonly encountered (so the case where you have duplicate values in index / column combinations, so when you need to use pivot_table
instead)
pandas/core/frame.py
Outdated
@@ -4341,27 +4341,31 @@ def last_valid_index(self): | |||
|
|||
def pivot(self, index=None, columns=None, values=None): | |||
""" | |||
Return reshaped DataFrame summarized by given index / column values. |
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 "summarized" is misleading here, as there is no "summary" (aggregation) calculation happening.
(I don't directly have the "better" wording in mind though. And the "reshaping" is important, as you already mention)
pandas/core/frame.py
Outdated
@@ -4341,27 +4341,31 @@ def last_valid_index(self): | |||
|
|||
def pivot(self, index=None, columns=None, values=None): | |||
""" | |||
Return reshaped DataFrame summarized by given index / column values. | |||
|
|||
Reshape data (produce a "pivot" table) based on column values. Uses | |||
unique values from index / columns to form axes of the resulting |
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 single backtick around index and column ? (to reference them as parameters).
I would maybe also say "from specified index / columns" to make it clear it is not the existing index / columns
pandas/core/frame.py
Outdated
columns : string or object | ||
Column name to use to make new frame's columns | ||
columns : string or object, optional | ||
Column name to use to make new frame's columns. |
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.
What happens in this case if you do not specify it?
pandas/core/frame.py
Outdated
Reshape data (produce a "pivot" table) based on column values. Uses | ||
unique values from index / columns to form axes of the resulting | ||
DataFrame. | ||
DataFrame. This function does not support data aggregation, multiple | ||
values will result in hierarchically indexed columns. | ||
|
||
Parameters | ||
---------- | ||
index : string or object, optional | ||
Column name to use to make new frame's index. If None, uses |
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.
Would it be clearer to just say "Column" instead of "Column name". I know the value you specify is the name, but what you actually use to make the new frame's index is the actual column, not the column name ...
Hello @amuta! Thanks for updating the PR.
Comment last updated on March 12, 2018 at 20:47 Hours UTC |
pandas/core/frame.py
Outdated
DataFrame. | ||
unique values from specified `index` / `columns` to form axes of the resulting | ||
DataFrame. This function does not support data aggregation, multiple | ||
values will result in hierarchically indexed columns. |
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.
in multiindexed columns.
Thanks @amuta ! |
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.