I'm attempting to group a dataframe by products, get a count of each product, and then sort so the most frequent product is at the top of the resulting series.
Currently my code looks like:
def return_most_products(self, df):
most_products_series = df.groupby('Product')['Product'].count()
most_products_series.sort_values()
return most_products_list
Which works to sort the series by the 'Product' column alphabetically. As the count column doesn't have a header that I can see I'm stumped as how to indicate that I want to index, and sort, based on the count rather than the product.