0
0
Pandasdata~15 mins

Why Pandas for data analysis - See It in Action

Choose your learning style9 modes available
Why Pandas for Data Analysis
📖 Scenario: Imagine you work in a small store. You have a list of sales data with product names and amounts sold. You want to understand this data quickly and easily.
🎯 Goal: You will create a simple table of sales data using Pandas, set a filter to find products with sales above a certain number, and then display those filtered results.
📋 What You'll Learn
Create a Pandas DataFrame with exact sales data
Create a variable to hold the sales threshold
Use Pandas filtering to select products with sales above the threshold
Print the filtered DataFrame
💡 Why This Matters
🌍 Real World
Stores and businesses use Pandas to quickly analyze sales data and make decisions.
💼 Career
Data analysts and scientists use Pandas daily to clean, filter, and explore data efficiently.
Progress0 / 4 steps
1
Create the sales data table
Import the pandas library as pd. Then create a DataFrame called sales_data with two columns: 'Product' and 'Sales'. Use these exact entries: 'Apples' with 50, 'Bananas' with 30, 'Cherries' with 20, 'Dates' with 15, and 'Elderberries' with 5.
Pandas
Need a hint?

Use pd.DataFrame with a dictionary where keys are column names and values are lists of data.

2
Set the sales threshold
Create a variable called threshold and set it to 20. This will help us find products with sales greater than this number.
Pandas
Need a hint?

Just assign the number 20 to a variable named threshold.

3
Filter products with sales above the threshold
Create a new DataFrame called filtered_sales by selecting rows from sales_data where the 'Sales' value is greater than threshold.
Pandas
Need a hint?

Use sales_data[sales_data['Sales'] > threshold] to filter the rows.

4
Display the filtered sales data
Print the filtered_sales DataFrame to see the products with sales above the threshold.
Pandas
Need a hint?

Use print(filtered_sales) to show the filtered table.