pandas.Index.drop_duplicates

pandas 3.1.1 · Index objects · method

Keep one occurrence of duplicate values or rows by default. Use keep to choose which occurrences survive.

Call syntax

Index.drop_duplicates(*, keep='first')

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
keep Optional
Keyword only
Default 'first'
{'first', 'last', False}

Choose which occurrence to retain when values are duplicated or tied.

Returns

Index