Complete the code to calculate the mean of the 'score' column using agg().
import pandas as pd data = {'name': ['Alice', 'Bob', 'Charlie'], 'score': [85, 90, 78]} df = pd.DataFrame(data) result = df['score'].agg([1]) print(result)
The agg() function applies the aggregation function specified. Here, 'mean' calculates the average score.
Complete the code to calculate both the minimum and maximum of the 'score' column using agg().
import pandas as pd data = {'name': ['Alice', 'Bob', 'Charlie'], 'score': [85, 90, 78]} df = pd.DataFrame(data) result = df['score'].agg([1]) print(result)
The agg() function accepts a list of function names to apply multiple aggregations. The list ['min', 'max'] calculates both minimum and maximum values.
Fix the error in the code to calculate the sum of 'score' and the mean of 'age' columns using agg().
import pandas as pd data = {'name': ['Alice', 'Bob'], 'score': [85, 90], 'age': [25, 30]} df = pd.DataFrame(data) result = df.agg({'score': [1], 'age': 'mean'}) print(result)
When specifying aggregation functions in a dictionary for agg(), function names must be strings like 'sum' or 'mean'.
Fill both blanks to create a dictionary that calculates the mean of 'score' and the max of 'age' using agg().
import pandas as pd data = {'name': ['Alice', 'Bob'], 'score': [85, 90], 'age': [25, 30]} df = pd.DataFrame(data) result = df.agg({'score': [1], 'age': [2]) print(result)
The dictionary keys are column names and values are aggregation functions as strings. Here, 'mean' for 'score' and 'max' for 'age' calculate the average score and maximum age.
Fill all three blanks to create a dictionary that calculates the sum of 'score', the mean of 'age', and the minimum of 'score' using agg().
import pandas as pd data = {'name': ['Alice', 'Bob'], 'score': [85, 90], 'age': [25, 30]} df = pd.DataFrame(data) result = df.agg({'score': [[1], [2]], 'age': [3]) print(result)
For the 'score' column, we pass a list of functions ['sum', 'min'] to calculate total and minimum scores. For 'age', 'mean' calculates the average age.