Skip to content

Commit 70802c2

Browse files
MaxVanDeursenjreback
authored andcommitted
DataFrame.drop Raises KeyError definition (#25474)
1 parent c986386 commit 70802c2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pandas/core/frame.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -3797,7 +3797,12 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
37973797
axis : {0 or 'index', 1 or 'columns'}, default 0
37983798
Whether to drop labels from the index (0 or 'index') or
37993799
columns (1 or 'columns').
3800-
index, columns : single label or list-like
3800+
index : single label or list-like
3801+
Alternative to specifying axis (``labels, axis=0``
3802+
is equivalent to ``index=labels``).
3803+
3804+
.. versionadded:: 0.21.0
3805+
columns : single label or list-like
38013806
Alternative to specifying axis (``labels, axis=1``
38023807
is equivalent to ``columns=labels``).
38033808
@@ -3813,11 +3818,12 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
38133818
Returns
38143819
-------
38153820
DataFrame
3821+
DataFrame without the removed index or column labels.
38163822
38173823
Raises
38183824
------
38193825
KeyError
3820-
If none of the labels are found in the selected axis
3826+
If any of the labels is not found in the selected axis.
38213827
38223828
See Also
38233829
--------
@@ -3830,7 +3836,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
38303836
38313837
Examples
38323838
--------
3833-
>>> df = pd.DataFrame(np.arange(12).reshape(3,4),
3839+
>>> df = pd.DataFrame(np.arange(12).reshape(3, 4),
38343840
... columns=['A', 'B', 'C', 'D'])
38353841
>>> df
38363842
A B C D
@@ -3867,7 +3873,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None,
38673873
>>> df = pd.DataFrame(index=midx, columns=['big', 'small'],
38683874
... data=[[45, 30], [200, 100], [1.5, 1], [30, 20],
38693875
... [250, 150], [1.5, 0.8], [320, 250],
3870-
... [1, 0.8], [0.3,0.2]])
3876+
... [1, 0.8], [0.3, 0.2]])
38713877
>>> df
38723878
big small
38733879
lama speed 45.0 30.0

0 commit comments

Comments
 (0)