I'm working with the Northwind database (download link, documentation).
I wanted to check the popularity of sold products, I did it in the following way
order_details_products = order_details.merge(products, on = 'productID') order_details_products_categories = order_details_products.merge(categories, on = 'categoryID') popularity_products = order_details_products_categories.groupby(['productID', 'categoryID', 'categoryName']).agg(no_orders = ('productID', 'count')) popularity_products.sort_values(by = 'no_orders', ascending = False, inplace = True) It works and it perfectly returns what I need. However there's an issue I don't know how to deal with. When I check the shape of my dataframe popularity_products I get the following output
popularity_products.shape Out[27]: (77, 1) That means that my dataframe contains only one column: no_orders. Is it possible to make a dataframe with 4 columns: productID, categoryID, categoryName?
Regards.
reset_indexor.to_frameto the end