File size: 160 Bytes
1849db4
 
 
 
1
2
3
4
5
def get_top_n_popular_items(df, n=10):
    top = df['product_id'].value_counts().head(n).reset_index()
    top.columns = ['product_id', 'count']
    return top