0
0
Pandasdata~15 mins

When to use NumPy over Pandas - Mini Project: Build & Apply

Choose your learning style9 modes available
When to use NumPy over Pandas
📖 Scenario: You work as a data analyst in a company that collects sales data. You have two tools to handle data: NumPy and Pandas. You want to learn when it is better to use NumPy instead of Pandas for your calculations.
🎯 Goal: Build a small program that creates sales data, sets a threshold, uses NumPy to filter data faster, and prints the filtered results.
📋 What You'll Learn
Create a NumPy array with sales numbers
Create a threshold variable to filter sales
Use NumPy to select sales above the threshold
Print the filtered sales array
💡 Why This Matters
🌍 Real World
Data analysts often choose NumPy for fast number crunching and Pandas for data tables with labels.
💼 Career
Knowing when to use NumPy helps you write faster, simpler code for numerical tasks in data science jobs.
Progress0 / 4 steps
1
Create a NumPy array with sales data
Import NumPy as np and create a NumPy array called sales with these exact values: 100, 250, 300, 150, 400.
Pandas
Need a hint?

Use np.array([...]) to create the array.

2
Set a sales threshold
Create a variable called threshold and set it to 200.
Pandas
Need a hint?

Just assign the number 200 to the variable threshold.

3
Filter sales above the threshold using NumPy
Create a new NumPy array called high_sales that contains only the values from sales that are greater than threshold. Use NumPy boolean indexing.
Pandas
Need a hint?

Use sales[sales > threshold] to filter the array.

4
Print the filtered sales
Print the high_sales array to show the sales values above the threshold.
Pandas
Need a hint?

Use print(high_sales) to display the filtered array.