Naposledy aktivní 1715848996

Revize 0525f9a3a2e8471603fe11127602ae477f731906

q28.py Raw
1# Create a .csv file (with contents like age, weight and BMI). Read the content of the file and using Pandas and
2# MatPlotLib, plot the graph.
3
4import numpy as np
5import pandas as pd
6import matplotlib.pyplot as plt
7
8data = pd.read_csv("data.csv")
9bmi = []
10for row in data.iterrows():
11 age, weight, height = row[1]
12 bmi.append(weight / (height / 100) ** 2)
13data["BMI"] = bmi
14
15figure, ax = plt.subplots()
16ax.plot(data["age"], data["BMI"], "ro")
17plt.show()
18