Q: extract duplicate values with 3 or more duplicates in a column pandas dataframe I'm trying to extract a dataframe which only shows duplicates with e.g 3 or more duplicates in a column. For example:
df = pd.DataFrame({
    'one': pd.Series(['Berlin', 'Berlin', 'Tokyo', 'Stockholm','Berlin','Stockholm','Amsterdam']),
    'two': pd.Series([1, 2, 3, 4, 5, 6, 7]),
    'three': pd.Series([8, 9, 10, 11, 12])
})

Expected output:
    one     two   three
0  Berlin    1      8

The extraction should only show the row of the first duplicate.

A: You could do it like this:
rows = df.groupby('one').filter(lambda group: group.shape[0] >= 3).groupby('one').first()   

Output:
>>> rows
           two  three
one                  
Amsterdam    7    1.0
Berlin       1    8.0

It works with multiple groups of 3+ duplicates, too. I tested it.
