I am trying to sort data by the Name
column, by popularity.
Right now, I'm doing this:
df['Count'] = df.apply(lambda x: len(df[df['Name'] == x['Name']]), axis=1)
df[df['Count'] > 50][['Name', 'Description', 'Count']].drop_duplicates('Name').sort_values('Count', ascending=False).head(100)
However this query is very slow, it takes hours to run.
What would be a more efficient way to do this?