I have a function that returns the BMI from a given dataframe with columns 'Weight' and 'Height'
Here is the function:
but instead of using the column 'Height', the calculation would be by using the new column 'Height In Meters'.
the result should be a new column called 'BMI' in the dataframe 'data', that shows for each row the calculation using 'Height In Meters'.
I tried:
Here is the function:
def BMI(data): return data['Weight']/(data['Height']**2)Now, i added new column 'Height In Meters' to the dataframe 'data' with:
data['Height In Meters']=data['Height']/100What i would like to do next, is to apply the original function on the dataframe 'data',
but instead of using the column 'Height', the calculation would be by using the new column 'Height In Meters'.
the result should be a new column called 'BMI' in the dataframe 'data', that shows for each row the calculation using 'Height In Meters'.
I tried:
data['BMI']=data[['Weight','Height In Meters']].apply(BMI,axis=1)But that doesn't seem to work.