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()