pandas.DataFrame.drop_duplicates¶
-
DataFrame.
drop_duplicates
(self, subset: Union[Hashable, Sequence[Hashable], NoneType] = None, keep: Union[str, bool] = 'first', inplace: bool = False, ignore_index: bool = False) → Union[ForwardRef('DataFrame'), NoneType][source]¶ Return DataFrame with duplicate rows removed.
Considering certain columns is optional. Indexes, including time indexes are ignored.
- Parameters
- subsetcolumn label or sequence of labels, optional
Only consider certain columns for identifying duplicates, by default use all of the columns.
- keep{‘first’, ‘last’, False}, default ‘first’
Determines which duplicates (if any) to keep. -
first
: Drop duplicates except for the first occurrence. -last
: Drop duplicates except for the last occurrence. - False : Drop all duplicates.- inplacebool, default False
Whether to drop duplicates in place or to return a copy.
- ignore_indexbool, default False
If True, the resulting axis will be labeled 0, 1, …, n - 1.
New in version 1.0.0.
- Returns
- DataFrame
DataFrame with duplicates removed or None if
inplace=True
.