Skip to content

Commit 2f33727

Browse files
committed
pandas-dev#48304 ENH: ignore_index to Series.drop_duplicates - Added ignore_index to series.py
1 parent ddf2541 commit 2f33727

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/core/series.py

+9
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,7 @@ def drop_duplicates(
22482248
keep: Literal["first", "last", False] = ...,
22492249
*,
22502250
inplace: Literal[False] = ...,
2251+
ignore_index: bool = False,
22512252
) -> Series:
22522253
...
22532254

@@ -2282,6 +2283,9 @@ def drop_duplicates(
22822283
inplace : bool, default ``False``
22832284
If ``True``, performs operation inplace and returns None.
22842285
2286+
ignore_index : bool, default False
2287+
If True, the resulting axis will be labeled 0, 1, …, n - 1.
2288+
22852289
Returns
22862290
-------
22872291
Series or None
@@ -2343,7 +2347,12 @@ def drop_duplicates(
23432347
Name: animal, dtype: object
23442348
"""
23452349
inplace = validate_bool_kwarg(inplace, "inplace")
2350+
ignore_index = validate_bool_kwarg(ignore_index, "ignore_index")
23462351
result = super().drop_duplicates(keep=keep)
2352+
2353+
if ignore_index:
2354+
result.index = reset_index(drop=False)
2355+
23472356
if inplace:
23482357
self._update_inplace(result)
23492358
return None

0 commit comments

Comments
 (0)