Skip to content

Commit adf2283

Browse files
author
aschade
committed
DOC: Updated docstring and documentation
1 parent fa4c9fe commit adf2283

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ Other API Changes
271271
- :class:`IntervalIndex` and ``IntervalDtype`` no longer support categorical, object, and string subtypes (:issue:`19016`)
272272
- The default ``Timedelta`` constructor now accepts an ``ISO 8601 Duration`` string as an argument (:issue:`19040`)
273273
- ``IntervalDtype`` now returns ``True`` when compared against ``'interval'`` regardless of subtype, and ``IntervalDtype.name`` now returns ``'interval'`` regardless of subtype (:issue:`18980`)
274+
- ``KeyError`` now raises instead of ``ValueError`` when using :meth:`drop()` to remove a non-existent element in an axis of ``Series``, ``Index``, ``DataFrame`` and ``Panel`` (:issue:`19186`)
274275

275276
.. _whatsnew_0230.deprecations:
276277

@@ -408,7 +409,7 @@ Indexing
408409
- Bug in :func:`MultiIndex.set_labels` which would cause casting (and potentially clipping) of the new labels if the ``level`` argument is not 0 or a list like [0, 1, ... ] (:issue:`19057`)
409410
- Bug in ``str.extractall`` when there were no matches empty :class:`Index` was returned instead of appropriate :class:`MultiIndex` (:issue:`19034`)
410411
- Bug in :class:`IntervalIndex` where set operations that returned an empty ``IntervalIndex`` had the wrong dtype (:issue:`19101`)
411-
- Bug in :func:`DataFrame.drop`, ``KeyError`` now raises when dropping an ``Index`` or column that has duplicates (:issue:`19186`)
412+
- Bug in :func:`DataFrame.drop`, where no ``Exception`` is raised when dropping a non-existent element from an axis in ``Index`` (:issue:`19186`)
412413
-
413414

414415
I/O

pandas/core/generic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,11 @@ def drop(self, labels=None, axis=0, index=None, columns=None, level=None,
28062806
-------
28072807
dropped : type of caller
28082808
2809+
Raises
2810+
------
2811+
KeyError
2812+
* If labels are not found in the selected axis
2813+
28092814
Examples
28102815
--------
28112816
>>> df = pd.DataFrame(np.arange(12).reshape(3,4),

pandas/core/indexes/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3760,6 +3760,11 @@ def drop(self, labels, errors='raise'):
37603760
Returns
37613761
-------
37623762
dropped : Index
3763+
3764+
Raises
3765+
------
3766+
KeyError
3767+
* If labels are not found in the selected axis
37633768
"""
37643769
arr_dtype = 'object' if self.dtype == 'object' else None
37653770
labels = _index_labels_to_array(labels, dtype=arr_dtype)

0 commit comments

Comments
 (0)