Skip to content

Commit 36f2fa6

Browse files
Mike Phungfeefladder
Mike Phung
authored andcommitted
DOC GH42756 Update documentation for pandas.DataFrame.drop to clarify tuples. (pandas-dev#42789)
1 parent d86dd4e commit 36f2fa6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pandas/core/frame.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -4754,7 +4754,8 @@ def drop(
47544754
Parameters
47554755
----------
47564756
labels : single label or list-like
4757-
Index or column labels to drop.
4757+
Index or column labels to drop. A tuple will be used as a single
4758+
label and not treated as a list-like.
47584759
axis : {0 or 'index', 1 or 'columns'}, default 0
47594760
Whether to drop labels from the index (0 or 'index') or
47604761
columns (1 or 'columns').
@@ -4845,6 +4846,17 @@ def drop(
48454846
weight 1.0 0.8
48464847
length 0.3 0.2
48474848
4849+
>>> df.drop(index=('falcon', 'weight'))
4850+
big small
4851+
lama speed 45.0 30.0
4852+
weight 200.0 100.0
4853+
length 1.5 1.0
4854+
cow speed 30.0 20.0
4855+
weight 250.0 150.0
4856+
length 1.5 0.8
4857+
falcon speed 320.0 250.0
4858+
length 0.3 0.2
4859+
48484860
>>> df.drop(index='cow', columns='small')
48494861
big
48504862
lama speed 45.0

0 commit comments

Comments
 (0)