Tell us what’s happening:
Hi, I am trying to answer question no.1 of the medical analyzer project.
Here is the question:
** Add an overweight
column to the data. To determine if a person is overweight, first calculate their BMI by dividing their weight in kilograms by the square of their height in meters. If that value is > 25 then the person is overweight. Use the value 0 for NOT overweight and the value 1 for overweight.*
My idea was to run a for loop going through all entries, calculating the BMI
for each of them and assigning a boolean to define overweight(1) or not (0).
However, after creating the new column, I can’t see the 0 or 1 boolean but
I actually see this:
<function overweight at 0x000002CAA89D2700>
Can I please ask if you can tell me:
- Why I can’t see true/false as intended
- If my whole reasoning to answer the question is correct, or it is completely wrong and I have to find a different way.
Thank you
here is my code
Your code so far
def overweight(df):
for id in df:
bmi = [‘weight’]/([‘height’]**2)
if bmi > 25:
bmi = True
else:
bmi = False
df[‘overweight’] = overweight
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Challenge: Medical Data Visualizer
Link to the challenge: