Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3797,7 +3797,12 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
axis : {0 or 'index', 1 or 'columns'}, default 0
Whether to drop labels from the index (0 or 'index') or
columns (1 or 'columns').
index, columns : single label or list-like
index : single label or list-like
Alternative to specifying axis (``labels, axis=0``
is equivalent to ``index=labels``).

.. versionadded:: 0.21.0
columns : single label or list-like
Alternative to specifying axis (``labels, axis=1``
is equivalent to ``columns=labels``).

Expand All @@ -3813,11 +3818,12 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
Returns
-------
DataFrame
DataFrame without the removed index or column labels.

Raises
------
KeyError
If none of the labels are found in the selected axis
If any of the labels is not found in the selected axis.

See Also
--------
Expand All @@ -3830,7 +3836,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None,

Examples
--------
>>> df = pd.DataFrame(np.arange(12).reshape(3,4),
>>> df = pd.DataFrame(np.arange(12).reshape(3, 4),
... columns=['A', 'B', 'C', 'D'])
>>> df
A B C D
Expand Down Expand Up @@ -3867,7 +3873,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
>>> df = pd.DataFrame(index=midx, columns=['big', 'small'],
... data=[[45, 30], [200, 100], [1.5, 1], [30, 20],
... [250, 150], [1.5, 0.8], [320, 250],
... [1, 0.8], [0.3,0.2]])
... [1, 0.8], [0.3, 0.2]])
>>> df
big small
lama speed 45.0 30.0
Expand Down