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