0
0
Data Analysis Pythondata~20 mins

Aggregation functions (sum, mean, std) in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Aggregation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of sum aggregation on DataFrame column
What is the output of the following code snippet?
Data Analysis Python
import pandas as pd

df = pd.DataFrame({'values': [10, 20, 30, 40]})
result = df['values'].sum()
print(result)
A40
BTypeError
C100
D25
Attempts:
2 left
💡 Hint
Sum adds all numbers in the column.
data_output
intermediate
2:00remaining
Mean value of grouped data
Given the DataFrame below, what is the mean value of group 'B'?
Data Analysis Python
import pandas as pd

df = pd.DataFrame({'group': ['A', 'B', 'B', 'A', 'B'], 'score': [5, 10, 15, 20, 25]})
mean_b = df.groupby('group')['score'].mean().loc['B']
print(mean_b)
A16.666666666666668
B15
C10
D20
Attempts:
2 left
💡 Hint
Mean is the sum divided by count for group 'B'.
Predict Output
advanced
2:00remaining
Standard deviation calculation on a list
What is the output of this code?
Data Analysis Python
import numpy as np

values = [2, 4, 4, 4, 5, 5, 7, 9]
std_dev = np.std(values, ddof=1)
print(round(std_dev, 2))
A2.14
B2.00
C2.31
D1.96
Attempts:
2 left
💡 Hint
ddof=1 means sample standard deviation.
visualization
advanced
2:00remaining
Interpreting aggregation results in a bar chart
You have this code that plots mean scores by category. What does the bar height for category 'X' represent?
Data Analysis Python
import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame({'category': ['X', 'Y', 'X', 'Y', 'X'], 'score': [3, 7, 5, 9, 4]})
mean_scores = df.groupby('category')['score'].mean()
mean_scores.plot(kind='bar')
plt.show()
AThe total sum of scores in category 'X'
BThe count of entries in category 'X'
CThe highest score recorded in category 'X'
DThe average score of all entries in category 'X'
Attempts:
2 left
💡 Hint
The code uses mean aggregation.
🧠 Conceptual
expert
2:00remaining
Understanding difference between population and sample std deviation
Which statement correctly explains the difference between population and sample standard deviation calculations?
APopulation std deviation divides by (n-1), sample divides by n
BSample std deviation divides by (n-1) to correct bias, population divides by n
CBoth divide by n but sample uses a different formula for variance
DSample std deviation always gives smaller values than population std deviation
Attempts:
2 left
💡 Hint
Think about degrees of freedom in statistics.