Skip to content

Commit 5776bf3

Browse files
author
aschade
committed
DOC/TST: Updated docstring to show method correctly and updated test
1 parent 556f959 commit 5776bf3

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

doc/source/whatsnew/v0.23.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ Other API Changes
272272
- :class:`IntervalIndex` and ``IntervalDtype`` no longer support categorical, object, and string subtypes (:issue:`19016`)
273273
- The default ``Timedelta`` constructor now accepts an ``ISO 8601 Duration`` string as an argument (:issue:`19040`)
274274
- ``IntervalDtype`` now returns ``True`` when compared against ``'interval'`` regardless of subtype, and ``IntervalDtype.name`` now returns ``'interval'`` regardless of subtype (:issue:`18980`)
275-
- ``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`)
275+
- ``KeyError`` now raises instead of ``ValueError`` in :meth:`~DataFrame.drop`, :meth:`~Panel.drop`, :meth:`~Series.drop`, :meth:`~Index.drop` when dropping a non-existent element in an axis with duplicates (:issue:`19186`)
276276
- :func:`Series.to_csv` now accepts a ``compression`` argument that works in the same way as the ``compression`` argument in :func:`DataFrame.to_csv` (:issue:`18958`)
277277

278278
.. _whatsnew_0230.deprecations:
@@ -416,7 +416,7 @@ Indexing
416416
- 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`)
417417
- Bug in ``str.extractall`` when there were no matches empty :class:`Index` was returned instead of appropriate :class:`MultiIndex` (:issue:`19034`)
418418
- Bug in :class:`IntervalIndex` where set operations that returned an empty ``IntervalIndex`` had the wrong dtype (:issue:`19101`)
419-
- Bug in :func:`Index.drop()`, where no ``Exception`` is raised when dropping a non-existent element from an axis in ``Index`` (:issue:`19186`)
419+
- Bug in :meth:`~DataFrame.drop`, :meth:`~Panel.drop`, :meth:`~Series.drop`, :meth:`~Index.drop` where no ``KeyError`` is raised when dropping a non-existent element from an axis that contains duplicates (:issue:`19186`)
420420
-
421421

422422
I/O

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ def drop(self, labels=None, axis=0, index=None, columns=None, level=None,
28092809
Raises
28102810
------
28112811
KeyError
2812-
* If labels are not found in the selected axis
2812+
If none of the labels are found in the selected axis
28132813
28142814
Examples
28152815
--------

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,7 @@ def drop(self, labels, errors='raise'):
37643764
Raises
37653765
------
37663766
KeyError
3767-
* If labels are not found in the selected axis
3767+
If none of the labels are found in the selected axis
37683768
"""
37693769
arr_dtype = 'object' if self.dtype == 'object' else None
37703770
labels = _index_labels_to_array(labels, dtype=arr_dtype)

pandas/tests/frame/test_axis_select_reindex.py

+1
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ def test_raise_on_drop_duplicate_index(self, actual):
11431143
level = 0 if isinstance(actual.index, MultiIndex) else None
11441144
with pytest.raises(KeyError):
11451145
actual.drop('c', level=level, axis=0)
1146+
with pytest.raises(KeyError):
11461147
actual.T.drop('c', level=level, axis=1)
11471148
expected_no_err = actual.drop('c', axis=0, level=level,
11481149
errors='ignore')

0 commit comments

Comments
 (0)