-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: update and seperate the Series.drop and Dataframe.drop docstring #20120
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 and seperate the Series.drop and Dataframe.drop docstring #20120
Conversation
Hello @JennaVergeynst! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 12, 2018 at 21:59 Hours UTC |
pandas/core/frame.py
Outdated
weight 1.0 0.8 | ||
""" | ||
return super(DataFrame, | ||
self).drop(labels=labels, axis=axis, index=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.
indendation is a bit strange here. I would set the self
on the same line
pandas/core/frame.py
Outdated
Whether to drop labels from the index (0 / 'index') or | ||
columns (1 / 'columns'). | ||
index : None | ||
Redundant for application on Series, but index can be used instead |
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.
As this is now in the data.frame
section, this is probably not redundant?
pandas/core/frame.py
Outdated
Redundant for application on Series, but index can be used instead | ||
of labels. | ||
columns : None | ||
Redundant for application on Series, but index can be used instead |
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.
As this is now in the data.frame
section, this is probably not redundant?
pandas/core/frame.py
Outdated
|
||
.. versionadded:: 0.21.0 | ||
level : int or level name, optional | ||
For MultiIndex. |
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.
Is it useful to make this more detailed? e.g. Level for which the labels will be removed
pandas/core/frame.py
Outdated
|
||
Returns | ||
------- | ||
dropped : type of caller |
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 the generic, this was the same as the caller, but here we know it is a dataframe
pandas/core/frame.py
Outdated
weight 1.0 0.8 | ||
length 0.3 0.2 | ||
|
||
>>> df.drop(index='cow',columns='small') |
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.
missing space after ,
pandas/core/frame.py
Outdated
|
||
Drop columns and/or rows of MultiIndex | ||
|
||
>>> midx = pd.MultiIndex(levels=[['lama','cow','falcon'], |
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.
missing spaces after ,
pandas/core/series.py
Outdated
|
||
Returns | ||
------- | ||
dropped : type of caller |
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.
pandas.Series
pandas/core/frame.py
Outdated
Index or column labels to drop. | ||
axis : int or axis name, default 0 | ||
Whether to drop labels from the index (0 / 'index') or | ||
columns (1 / '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.
I would write (0 or 'index') and columns (1 or 'columns')
pandas/core/frame.py
Outdated
---------- | ||
labels : single label or list-like | ||
Index or column labels to drop. | ||
axis : int or axis name, default 0 |
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.
cfr. gitter discussion: axis : {0 or 'index', 1 or 'columns'}, default 0
pandas/core/frame.py
Outdated
DataFrame.dropna : Return DataFrame with labels on given axis omitted | ||
where (all or any) data are missing | ||
DataFrame.drop_duplicates : Return DataFrame with duplicate rows | ||
removed, optionally only considering certain 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.
reference DataFrame.loc (first) as well as this is an indexing operations
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.
also Series.drop
pandas/core/frame.py
Outdated
A B C D | ||
2 8 9 10 11 | ||
|
||
Drop columns and/or rows of MultiIndex |
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.
MultiIndexed DataFrame
pandas/core/frame.py
Outdated
[0.3,0.2]]) | ||
>>> df | ||
big small | ||
lama speed 45.0 30.0 |
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 don't think this is layed out correctly, a copy-paste issue?
pandas/core/frame.py
Outdated
>>> midx = pd.MultiIndex(levels=[['lama','cow','falcon'], | ||
... ['speed','weight','length']], | ||
... labels=[[0, 0, 0, 1, 1, 1, 2, 2, 2], | ||
... [0, 1, 2, 0, 1, 2, 0, 1, 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.
I would make this example a bit simpler, maybe using integers for the value column (and order them, e.g. use np.arange(len(midx))
to create (big/small)
pandas/core/frame.py
Outdated
DataFrame.dropna : Return DataFrame with labels on given axis omitted | ||
where (all or any) data are missing | ||
DataFrame.drop_duplicates : Return DataFrame with duplicate rows | ||
removed, optionally only considering certain 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.
also Series.drop
Codecov Report
@@ Coverage Diff @@
## master #20120 +/- ##
==========================================
- Coverage 91.72% 91.7% -0.03%
==========================================
Files 150 150
Lines 49156 49156
==========================================
- Hits 45090 45078 -12
- Misses 4066 4078 +12
Continue to review full report at Codecov.
|
@JennaVergeynst Thanks for the PR! |
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:
This error is caused by
.. versionadded:: 0.21.0
, which needs to stay in place.