Help needed with medycal data analyzer project

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:

  1. Why I can’t see true/false as intended
  2. 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
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:

This means you’ve assigned the function itself, not the result of executing the function (in other words, no parentheses and no arguments). It happened here:

You need to call your function as overweight(df) and it will return the result, although your function is only calculating bmi and not actually adding it to the data frame. It also does not have a return statement.

Also, use code blocks (preformatted text or backticks) for posting code. It’s easier for all involved if you just post a link to the live project on or similar site anyway.

Hi Jeremy,

thank you for the explanation and the tips

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.