0
0
Data Analysis Pythondata~10 mins

Sales data analysis pattern in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load the sales data from a CSV file into a DataFrame.

Data Analysis Python
import pandas as pd
sales_data = pd.read_csv([1])
Drag options to blanks, or click blank then click option'
A'sales.csv'
Bsales.csv
Cdata.csv
D"sales_data"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name.
Using a variable name instead of a string.
2fill in blank
medium

Complete the code to calculate the total sales by summing the 'Amount' column.

Data Analysis Python
total_sales = sales_data[[1]].sum()
Drag options to blanks, or click blank then click option'
A'Total'
B'Price'
C'Amount'
D'Sales'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name.
Forgetting quotes around the column name.
3fill in blank
hard

Fix the error in the code to group sales by 'Region' and calculate the mean sales amount.

Data Analysis Python
mean_sales_by_region = sales_data.groupby([1])['Amount'].mean()
Drag options to blanks, or click blank then click option'
A'Region'
BRegion
Cregion
D"region"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the column name without quotes.
Using incorrect capitalization.
4fill in blank
hard

Fill both blanks to create a dictionary of total sales for products with sales greater than 1000.

Data Analysis Python
high_sales = {product: sales_data[sales_data['Product'] == product][[1]].sum() for product in sales_data['Product'].unique() if sales_data[sales_data['Product'] == product][[2]].sum() > 1000}
Drag options to blanks, or click blank then click option'
A'Amount'
B'Sales'
C'Price'
D'Quantity'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different column names for the sums.
Using columns that do not represent sales amount.
5fill in blank
hard

Fill all three blanks to create a dictionary of average sales per region for products with average sales above 500.

Data Analysis Python
avg_sales = {region: sales_data[sales_data['Region'] == region][[1]].mean() for region in sales_data['Region'].unique() if sales_data[sales_data['Region'] == region][[2]].mean() > [3]
Drag options to blanks, or click blank then click option'
A'Amount'
C500
D1000
Attempts:
3 left
💡 Hint
Common Mistakes
Using different columns for mean calculation and filtering.
Using the wrong threshold value.