0
0
Data Analysis Pythondata~10 mins

Aggregation functions (sum, mean, count) 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 calculate the total sales using sum.

Data Analysis Python
total_sales = df['sales'].[1]()
Drag options to blanks, or click blank then click option'
Amean
Bsum
Ccount
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean() instead of sum() which calculates average.
Using count() which counts entries, not sums values.
2fill in blank
medium

Complete the code to find the average age using mean.

Data Analysis Python
average_age = df['age'].[1]()
Drag options to blanks, or click blank then click option'
Amin
Bsum
Ccount
Dmean
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() which adds values instead of averaging.
Using count() which counts entries, not averages.
3fill in blank
hard

Fix the error in the code to count the number of entries in the 'product' column.

Data Analysis Python
product_count = df['product'].[1]()
Drag options to blanks, or click blank then click option'
Acount
Bsum
Cmean
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() which adds values instead of counting.
Using mean() which calculates average, not count.
4fill in blank
hard

Fill both blanks to create a dictionary with total and average sales.

Data Analysis Python
sales_summary = {'total': df['sales'].[1](), 'average': df['sales'].[2]()}
Drag options to blanks, or click blank then click option'
Asum
Bmean
Ccount
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sum and mean functions.
Using count instead of sum or mean.
5fill in blank
hard

Fill all three blanks to create a dictionary with count, total, and average of 'quantity'.

Data Analysis Python
quantity_stats = {'count': df['quantity'].[1](), 'total': df['quantity'].[2](), 'average': df['quantity'].[3]()}
Drag options to blanks, or click blank then click option'
Amean
Bsum
Ccount
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean for count or sum.
Mixing order of functions.