0
0
Pandasdata~30 mins

Pandas and NumPy connection - Mini Project: Build & Apply

Choose your learning style9 modes available
Pandas and NumPy connection
📖 Scenario: You work in a small store that tracks daily sales data. You want to analyze the sales numbers using Python. You will use pandas to organize the data and numpy to perform calculations.
🎯 Goal: Create a pandas DataFrame from a numpy array of sales data, then calculate the average sales using numpy.
📋 What You'll Learn
Create a numpy array with exact sales data
Create a pandas DataFrame from the numpy array
Calculate the average sales using numpy
Print the average sales value
💡 Why This Matters
🌍 Real World
Stores and businesses often collect sales data daily. Using pandas and numpy together helps organize and analyze this data quickly.
💼 Career
Data analysts and scientists use pandas and numpy to clean, organize, and analyze data efficiently in many industries.
Progress0 / 4 steps
1
Create a numpy array with sales data
Create a numpy array called sales_data with these exact values: 100, 150, 200, 130, 170.
Pandas
Need a hint?

Use np.array([...]) to create the array with the exact numbers.

2
Create a pandas DataFrame from the numpy array
Import pandas as pd and create a DataFrame called df from the sales_data numpy array. Name the column 'Sales'.
Pandas
Need a hint?

Use pd.DataFrame() with columns=['Sales'] to name the column.

3
Calculate the average sales using numpy
Create a variable called average_sales and set it to the mean of the 'Sales' column in df using numpy.
Pandas
Need a hint?

Use np.mean() on the DataFrame column df['Sales'].

4
Print the average sales
Write a print statement to display the value of average_sales.
Pandas
Need a hint?

Use print(average_sales) to show the result.