A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/docs/dev/user_guide/../reference/api/pandas.Index.drop_duplicates.html below:

pandas.Index.drop_duplicates — pandas 3.0.0.dev0+2231.g4f2aa4d2be documentation

pandas.Index.drop_duplicates#
Index.drop_duplicates(*, keep='first')[source]#

Return Index with duplicate values removed.

Parameters:
keep{‘first’, ‘last’, False}, default ‘first’
  • ‘first’ : Drop duplicates except for the first occurrence.

  • ‘last’ : Drop duplicates except for the last occurrence.

  • False : Drop all duplicates.

Returns:
Index

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