0 votes
in Python by
How would you find duplicate values in a dataset for a variable in Python?

1 Answer

0 votes
by

You can check for duplicates using the Pandas duplicated() method. This will return a boolean series which is TRUE only for unique elements.

DataFrame.duplicated(subset=None,keep='last')

In this example, keep determines what to do with duplicates. You can use

First - Considers the first value unique and the rest as duplicates.

Last - Considers the last value unique and the rest as duplicates.

False - Considers all same values as duplicates.

...