Q#69: Normalizing student grades against median
You are given a dataframe containing student information, named df (shown below). Suppose you want to normalize each student’s grade based on the group’s median age.
Write a function using Python (Pandas) that will add a new column to your dataframe containing a new grade normalized against the median age of the students.
TRY IT YOURSELF
ANSWER
This question tests our understanding of Normalization as well as some basic pandas operations.
Normalization is simply a term for the rescaling of data values, usually in the effort to make it comparable to other data values or remove units of measure. In this question we are asked to normalize the grade column based on its median. In Pandas this is as simple as just dividing the column itself by the column called with the chained function .median().
df['grade_normalized'] = df['Grade']/df['Grade'].median()