I am a newbie here. English is not my native language so excuse any grammatical mistakes. I need to compute the average BMI per hair colour using the df.
# 1. Here we import pandas
import pandas as pd
# 2. Here we import numpy
import numpy as np
np.random.seed(0)
df = pd.DataFrame({'Age':[18, 21, 28, 19, 23, 22, 18, 24, 25, 20],
'Hair colour':['Blonde', 'Brown', 'Black', 'Blonde', 'Blonde', 'Black','Brown', 'Brown', 'Black', 'Black'],
'Length (in cm)':np.random.normal(175, 10, 10).round(1),
'Weight (in kg)':np.random.normal(70, 5, 10).round(1)},
index = ['Leon', 'Mirta', 'Nathan', 'Linda', 'Bandar', 'Violeta', 'Noah', 'Niji', 'Lucy', 'Mark'],)
I should get vectors with names.
Firstly, I wrote the function of BMI:
# function
def BMI():
df['weight (in kg)'] / (df['Length']/100)**2
However, I don't know what my next step is.
Can you advise me on how to find the average BMI per hair colour?