Last active 1715848996

sujal's Avatar sujal revised this gist 1715848996. Go to revision

1 file changed, 17 insertions

q28.py(file created)

@@ -0,0 +1,17 @@
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 +
4 + import numpy as np
5 + import pandas as pd
6 + import matplotlib.pyplot as plt
7 +
8 + data = pd.read_csv("data.csv")
9 + bmi = []
10 + for row in data.iterrows():
11 + age, weight, height = row[1]
12 + bmi.append(weight / (height / 100) ** 2)
13 + data["BMI"] = bmi
14 +
15 + figure, ax = plt.subplots()
16 + ax.plot(data["age"], data["BMI"], "ro")
17 + plt.show()
Newer Older