Return Index with duplicate values removed.
False
}, default âfirstâ
âfirstâ : Drop duplicates except for the first occurrence.
âlastâ : Drop duplicates except for the last occurrence.
False
: Drop all duplicates.
A new Index object with the duplicate values removed.
Examples
Generate an pandas.Index with duplicate values.
>>> idx = pd.Index(["llama", "cow", "llama", "beetle", "llama", "hippo"])
The keep parameter controls which duplicate values are removed. The value âfirstâ keeps the first occurrence for each set of duplicated entries. The default value of keep is âfirstâ.
>>> idx.drop_duplicates(keep="first") Index(['llama', 'cow', 'beetle', 'hippo'], dtype='object')
The value âlastâ keeps the last occurrence for each set of duplicated entries.
>>> idx.drop_duplicates(keep="last") Index(['cow', 'beetle', 'llama', 'hippo'], dtype='object')
The value False
discards all sets of duplicated entries.
>>> idx.drop_duplicates(keep=False) Index(['cow', 'beetle', 'hippo'], 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