Complete the code to calculate the mean of the 'score' column using agg().
import pandas as pd data = {'score': [10, 20, 30, 40, 50]} df = pd.DataFrame(data) result = df['score'].agg([1]) print(result)
The agg() function can take a string with the aggregation method name. Here, 'mean' calculates the average.
Complete the code to calculate both the minimum and maximum of the 'score' column using agg().
import pandas as pd data = {'score': [5, 15, 25, 35, 45]} df = pd.DataFrame(data) result = df['score'].agg([[1]]) print(result)
To apply multiple aggregations, pass a list of method names to agg(). Here, ['min', 'max'] calculates both minimum and maximum.
Fix the error in the code to calculate the sum and mean of the 'score' column using agg().
import pandas as pd data = {'score': [2, 4, 6, 8, 10]} df = pd.DataFrame(data) result = df['score'].agg([1]) print(result)
The agg() function expects a list of aggregation names to apply multiple functions. Passing a list like ['sum', 'mean'] is correct.
Fill both blanks to create a dictionary for agg() that calculates the mean and sum of 'score' and the max of 'age'.
import pandas as pd data = {'score': [1, 2, 3], 'age': [20, 30, 40]} df = pd.DataFrame(data) result = df.agg({'score': [1], 'age': [2]) print(result)
For multiple aggregations on 'score', use a list like ['mean', 'sum']. For 'age', a single aggregation like 'max' is enough.
Fill all three blanks to create a dictionary for agg() that calculates the sum of 'sales', the mean of 'profit', and the max of 'quantity'.
import pandas as pd data = {'sales': [100, 200, 300], 'profit': [10, 20, 30], 'quantity': [1, 2, 3]} df = pd.DataFrame(data) result = df.agg({'sales': [1], 'profit': [2], 'quantity': [3]) print(result)
Use 'sum' for 'sales', 'mean' for 'profit', and 'max' for 'quantity' in the aggregation dictionary.