Skip to content

Instantly share code, notes, and snippets.

@j450h1
Created June 12, 2020 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j450h1/9713d04d825ee043fc49dcaabf3245ca to your computer and use it in GitHub Desktop.
Save j450h1/9713d04d825ee043fc49dcaabf3245ca to your computer and use it in GitHub Desktop.
def topn_values(column_name, n):
"""
Take a column name and find the most frequent values
"""
return df.groupby(column_name).count().sort('count', ascending=False).limit(n).toPandas()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment