Skip to content

Commit

Permalink
pandas-dev#48304 ENH: ignore_index to Series.drop_duplicates - Added …
Browse files Browse the repository at this point in the history
…ignore_index to series.py
  • Loading branch information
lukaskuhn-lku committed Sep 4, 2022
1 parent ddf2541 commit 2f33727
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,7 @@ def drop_duplicates(
keep: Literal["first", "last", False] = ...,
*,
inplace: Literal[False] = ...,
ignore_index: bool = False,
) -> Series:
...

Expand Down Expand Up @@ -2282,6 +2283,9 @@ def drop_duplicates(
inplace : bool, default ``False``
If ``True``, performs operation inplace and returns None.
ignore_index : bool, default False
If True, the resulting axis will be labeled 0, 1, …, n - 1.
Returns
-------
Series or None
Expand Down Expand Up @@ -2343,7 +2347,12 @@ def drop_duplicates(
Name: animal, dtype: object
"""
inplace = validate_bool_kwarg(inplace, "inplace")
ignore_index = validate_bool_kwarg(ignore_index, "ignore_index")
result = super().drop_duplicates(keep=keep)

if ignore_index:
result.index = reset_index(drop=False)

if inplace:
self._update_inplace(result)
return None
Expand Down

0 comments on commit 2f33727

Please sign in to comment.