Skip to content

Instantly share code, notes, and snippets.

@j450h1
Created June 12, 2020 06:11
Show Gist options
  • Select an option

  • Save j450h1/9713d04d825ee043fc49dcaabf3245ca to your computer and use it in GitHub Desktop.

Select an option

Save j450h1/9713d04d825ee043fc49dcaabf3245ca to your computer and use it in GitHub Desktop.

Revisions

  1. j450h1 created this gist Jun 12, 2020.
    5 changes: 5 additions & 0 deletions topn_values
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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()