Please refer to the sample below.
import pandas as pd
df = pd.DataFrame(data={'alphabet':['a', 'a', 'a', 'b', 'b', 'c'], 'NNN':range(6), 'MMM':range(6)})
df.groupby('alphabet').filter(lambda x: x['alphabet'].count() > 1)
alphabet NNN MMM
0 a 0 0
1 a 1 1
2 a 2 2
3 b 3 3
4 b 4 4
© 2024 OneMinuteCode. All rights reserved.