Complete the code to calculate the mean of the 'score' column grouped by 'team'.
mean_scores = df.groupby('team')['score'].[1]()
The mean() function calculates the average value of the 'score' for each group defined by 'team'.
Complete the code to normalize the 'score' column by subtracting the group mean using transform.
df['score_normalized'] = df['score'] - df.groupby('team')['score'].[1]
The transform('mean') returns the mean for each group aligned with the original DataFrame, allowing element-wise subtraction.
Fix the error in the code to correctly normalize 'score' by group using transform.
df['score_norm'] = df.groupby('team')['score'].[1]('mean')
The transform method applies the function and returns a Series aligned with the original DataFrame, which is needed for element-wise operations.
Fill both blanks to create a normalized score by subtracting the group mean and dividing by the group standard deviation.
df['score_norm'] = (df['score'] - df.groupby('team')['score'].[1]) / df.groupby('team')['score'].[2]
Using transform('mean') and transform('std') returns Series aligned with the original DataFrame, allowing element-wise normalization.
Fill all three blanks to create a new column with z-score normalization of 'score' grouped by 'team' using transform.
df['score_z'] = (df[[1]] - df.groupby([2])[[3]].transform('mean')) / df.groupby([2])[[3]].transform('std')
The column to normalize is 'score' (string), and the grouping column is 'team' (string). Using strings is required for pandas indexing.