The document outlines a series of intermediate-level NumPy tasks focused on analyzing a dataset of monthly sales for three products across four regions. It includes operations such as boolean masking, slicing, aggregation, and calculations of averages and totals. The tasks aim to enhance understanding of NumPy functionalities related to data manipulation and analysis.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views1 page
Numpy Intermediate Boolean Slicing Aggregate
The document outlines a series of intermediate-level NumPy tasks focused on analyzing a dataset of monthly sales for three products across four regions. It includes operations such as boolean masking, slicing, aggregation, and calculations of averages and totals. The tasks aim to enhance understanding of NumPy functionalities related to data manipulation and analysis.
Dataset: Monthly sales (in units) for 3 products (columns) over 4 regions (rows)
1. Get the sales values greater than 160.
2. Replace all values below 140 with 0 using boolean masking. 3. Get sales data for the second product only. 4. Get sales values of regions 2 and 3 (index 1 and 2). 5. Find the total sales per product using aggregate function. 6. Calculate the average sales per region. 7. What is the maximum sale across all regions and products? 8. Identify which products had sales above 180 in any region. 9. Extract the region with the highest total sales. 10. Apply a 10% increase to all sales using broadcasting. 11. Mask values between 140 and 180 (inclusive). 12. Set all values > 175 to the product of 2. 13. Create a new array showing only sales of product 1 and 3 for regions 1 and 4. 14. Find the number of times a sale of 170 occurred. 15. What is the average sale for product 2 across all regions? 16. Replace values less than the mean with -1 using np.where. 17. Count how many products in each region sold more than 150. 18. What is the minimum sale in region 4? 19. Use slicing to get the last two regions and last two products. 20. Find which region had the most consistent sales (lowest std deviation).