0
0
Data Analysis Pythondata~10 mins

Aggregation-based features 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 mean of the 'sales' column.

Data Analysis Python
mean_sales = df['sales'].[1]()
Drag options to blanks, or click blank then click option'
Asum
Bmax
Cmean
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() instead of mean()
Using count() which counts entries, not averages
2fill in blank
medium

Complete the code to group data by 'category' and calculate the sum of 'amount'.

Data Analysis Python
grouped = df.groupby('[1]')['amount'].sum()
Drag options to blanks, or click blank then click option'
Aregion
Bdate
Csales
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by wrong column like 'date' or 'region'
Not grouping at all before summing
3fill in blank
hard

Fix the error in the code to calculate the maximum 'score' per 'team'.

Data Analysis Python
max_scores = df.groupby('team')['[1]'].max()
Drag options to blanks, or click blank then click option'
Ascores
Bscore
CScore
Dteam
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'scores' or 'Score' which do not match the column name
Grouping by the wrong column
4fill in blank
hard

Fill both blanks to create a dictionary of average 'price' for items with 'quantity' greater than 5.

Data Analysis Python
avg_price = {item: [1] for item, qty in data.items() if qty [2] 5}
Drag options to blanks, or click blank then click option'
Aprice_data[item]
B>
C<
Dquantity_data[item]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names for price or quantity
Using wrong comparison operator
5fill in blank
hard

Fill all three blanks to create a dictionary of total 'sales' for each 'region' where sales are above 1000.

Data Analysis Python
total_sales = { [1]: [2] for [3], sales in sales_data.items() if sales > 1000 }
Drag options to blanks, or click blank then click option'
Aregion
Bsales
Dregion_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently
Confusing keys and values in the dictionary comprehension