You essentially need to replicate the barchart in examples/Figure_1.png
What specifically are you struggling with?
Are you just not understanding this bit?
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.
Well, you are almost doing everything you need here:
a = (medfile["height"]**2)
Now, where is the weight property?
You have correctly accessed the height property
You have correctly performed a mathematical operation on it
How do you think you can divide weight by height, now?
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I’m thinking of this formula to divide the columns.
overweight = (“a”, / medfile[“weight”])
But when but I tried it it didn’t work. If I do that i would then need to appended the result to the csv file as a new bracket. Then break it down into a list so I can plot it to a barchart.
The video quality wasn’t working with my eyes, so I couldn’t follow along carefully. An finding the right information elsewhere is tedious as well.
I really don’t mean to be a bother, but I’m stuck. I have already created the "overweight " column, but need some help inserting it into the data. Each time I run it i get “None”.
code so far:
</>import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
medfile = pd.read_csv("medical_examination.csv",)
overweight = ((medfile["height"]**2) / medfile["weight"])
print(medfile.insert(loc=13, column="overweight", value=overweight))</>
I do not intend to be mean here: This kind of data/variable accessing/creating is very basic to every programming language, and looks almost identical in most programming languages. If this is new to you, I would recommend you go back over the Python for Everybody section which should cover this.
Hope this helps
Also, please read what I mentioned above about putting code in this forum. It is very important to correctly format Python code, because indentation is important.