Find Top and Bottom Sales Using nlargest() and nsmallest()
📖 Scenario: You work in a store and have a list of products with their sales numbers. You want to find which products sold the most and which sold the least.
🎯 Goal: Use pandas nlargest() and nsmallest() functions to find the top 3 and bottom 2 selling products from the sales data.
📋 What You'll Learn
Create a pandas DataFrame with product names and their sales numbers.
Create a variable to store the number of top and bottom products to find.
Use
nlargest() to find the top 3 selling products.Use
nsmallest() to find the bottom 2 selling products.Print the results clearly.
💡 Why This Matters
🌍 Real World
Stores and businesses often need to quickly find their best and worst selling products to make decisions about stock and promotions.
💼 Career
Data analysts and data scientists use functions like <code>nlargest()</code> and <code>nsmallest()</code> to summarize and report key insights from sales data.
Progress0 / 4 steps