import pandas as pd
Data = {'participant': ['Jordan', 'Jess', 'Jake', 'Alice', 'Alan', 'Lauren'], 'Age': [26, 23, 19, 20, 24, 28], 'Sex': ['M', 'F', 'M', 'F', 'M', 'F'], 'BMI': [26, 22, 24, 17, 35, 20], 'Smokes': ['No', 'No', 'Yes', 'No', 'Yes', 'No']}
df = pd.DataFrame(Data)
print(df)
for name in 'participant':
for ages in 'Age':
for sexs in 'Sex':
for Bmis in 'BMI':
for smoke in 'Smokes':
if nmb.find(str(30)) >= 30:
print('participant')
else:
print('none found')
question: What line of code would bring down the participants name that has a BMI of 30 or higher? How would i implant that?
print( df[df["BMI"] >= 30] )df["BMI"] will be the BMI column of the dataframe that will be compared element by element to 30. This boolean list is then used to select the respective rows. You should read more about python list basics and have a look into the pandas documentation to get started.