Skip to content

API: harmonize drop/reindex/rename args (GH12392) - drop #17644

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

Merged

Conversation

jorisvandenbossche
Copy link
Member

xref #12392.
For now this only deals with drop (making it similar with reindex), and not the other way around (reindex similar to drop). So the title is not fully correct, but this is the more easy part.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm some minor doc comments
prob should update usage in the main docs

@@ -89,6 +89,24 @@ This does not raise any obvious exceptions, but also does not create a new colum

Setting a list-like data structure into a new attribute now raise a ``UserWarning`` about the potential for unexpected behavior. See :ref:`Attribute Access <indexing.attribute_access>`.

``drop`` now also accepts index/columns keywords
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add ref here

Copy link
Member Author

@jorisvandenbossche jorisvandenbossche Sep 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only needed when you actually want to explicitly link to it from somewhere else in the docs, so I personally prefer to only add it when actually needed

(bug can certainly add it for consistency)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, all sub-sections should have a reference as a general rule. yes we may not always link to it, but by definition when creating a non-trivial sub-section it should have a reference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing "by definition" about it (I mean, sphinx does not require it). IMO it just gives more overhead by always asking contributors to do this.

return obj

def _drop_axis(self, labels, axis, level=None, errors='raise'):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add doc string here

res1 = df.drop(['a'], axis=0).drop(['d'], axis=1)
res2 = df.drop(index=['a'], columns=['d'])
tm.assert_frame_equal(res1, res2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with columns as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean for the error test? (added one for that) Or for one of the tests above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

axis : int or axis name
Whether to drop labels from the index (0 / 'index') or
columns (1 / 'columns').
index, columns : single label or list-like
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a Notes section saying that specifying both labels and index or columns will raise an error.

@codecov
Copy link

codecov bot commented Sep 23, 2017

Codecov Report

Merging #17644 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17644      +/-   ##
==========================================
- Coverage   91.22%    91.2%   -0.02%     
==========================================
  Files         163      163              
  Lines       49655    49669      +14     
==========================================
+ Hits        45297    45301       +4     
- Misses       4358     4368      +10
Flag Coverage Δ
#multiple 88.99% <100%> (ø) ⬆️
#single 40.18% <72.22%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 92.04% <100%> (+0.05%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.77% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.43% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4004367...88ec872. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 23, 2017

Codecov Report

Merging #17644 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17644      +/-   ##
==========================================
- Coverage   91.22%    91.2%   -0.02%     
==========================================
  Files         163      163              
  Lines       49655    49669      +14     
==========================================
+ Hits        45297    45301       +4     
- Misses       4358     4368      +10
Flag Coverage Δ
#multiple 88.99% <100%> (ø) ⬆️
#single 40.18% <72.22%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 92.04% <100%> (+0.05%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.77% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.43% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4004367...88ec872. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 23, 2017

Codecov Report

Merging #17644 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17644      +/-   ##
==========================================
- Coverage   91.26%   91.24%   -0.02%     
==========================================
  Files         163      163              
  Lines       49776    49790      +14     
==========================================
+ Hits        45426    45431       +5     
- Misses       4350     4359       +9
Flag Coverage Δ
#multiple 89.04% <100%> (ø) ⬆️
#single 40.29% <72.22%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 92.05% <100%> (+0.05%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.77% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d43aba8...ef82853. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments. merge on green.

columns (1 / 'columns').
index, columns : single label or list-like
Alternative to specifying `axis` (``labels, axis=1`` is
equivalent to ``columns=labels``).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a versionadded tag

res1 = df.drop(['a'], axis=0).drop(['d'], axis=1)
res2 = df.drop(index=['a'], columns=['d'])
tm.assert_frame_equal(res1, res2)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

@jreback jreback added this to the 0.21.0 milestone Sep 23, 2017
@TomAugspurger TomAugspurger merged commit ae16bf9 into pandas-dev:master Sep 24, 2017
@TomAugspurger
Copy link
Contributor

Thanks Joris!

alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
…17644)

* API: harmonize drop/reindex/rename args (GH12392) - drop

* fixups

* add versionadded
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
…17644)

* API: harmonize drop/reindex/rename args (GH12392) - drop

* fixups

* add versionadded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants