Examples
By default, for each set of duplicated values, the first occurrence is set on False and all others on True:
import numpy as np
import pandas as pd
animals = pd.Series(['dog', 'cow', 'dog', 'cat', 'dog'])
animals.duplicated()
which is equivalent to
animals.duplicated(keep='first')
By using ‘last’, the last occurrence of each set of duplicated values is set on False and all others on True:
animals.duplicated(keep='last')
By setting keep on False, all duplicates are True:
animals.duplicated(keep=False)