diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 608e5c53ec094..a40733b7076b0 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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``). @@ -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 -------- @@ -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 @@ -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