Return Series with duplicate values removed.
False
}, default âfirstâ
Method to handle dropping duplicates:
âfirstâ : Drop duplicates except for the first occurrence.
âlastâ : Drop duplicates except for the last occurrence.
False
: Drop all duplicates.
False
If True
, performs operation inplace and returns None.
False
If True
, the resulting axis will be labeled 0, 1, â¦, n - 1.
Added in version 2.0.0.
Series with duplicates dropped or None if inplace=True
.
Examples
Generate a Series with duplicated entries.
>>> s = pd.Series(['llama', 'cow', 'llama', 'beetle', 'llama', 'hippo'], ... name='animal') >>> s 0 llama 1 cow 2 llama 3 beetle 4 llama 5 hippo Name: animal, dtype: object
With the âkeepâ parameter, the selection behaviour of duplicated values can be changed. The value âfirstâ keeps the first occurrence for each set of duplicated entries. The default value of keep is âfirstâ.
>>> s.drop_duplicates() 0 llama 1 cow 3 beetle 5 hippo Name: animal, dtype: object
The value âlastâ for parameter âkeepâ keeps the last occurrence for each set of duplicated entries.
>>> s.drop_duplicates(keep='last') 1 cow 3 beetle 4 llama 5 hippo Name: animal, dtype: object
The value False
for parameter âkeepâ discards all sets of duplicated entries.
>>> s.drop_duplicates(keep=False) 1 cow 3 beetle 5 hippo Name: animal, dtype: object
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4