I have a pandas dataframe
import pandas as pd
df =pd.DataFrame({'name':['john','joe','bill','richard','sam'],
'cluster':['1','2','3','1','2']})
df['cluster'].value_counts() will give the number of occurrences of items based on the column cluster.
Is it possible to retain only the rows which have the maximum number of occurrences in the column cluster?
The expected output is
The cluster 1 and 2 have the same number of occurrences, so all the rows for cluster 1 and 2 need to be retained.

