AIM-PIbd-32-Borovkov-M-V/Lab_1/lab1.ipynb
2024-09-28 12:04:10 +04:00

158 KiB

In [78]:
import pandas as pd

df = pd.read_csv("../data/healthcare-dataset-stroke-data.csv", index_col="id")

data = df.copy()
hypertension_df = data[data["hypertension"] == 1]
heart_disease_df = data[data["heart_disease"] == 1]

hypertension_df.groupby(["gender"]).size().plot(kind='pie', y='gender', autopct='%1.0f%%')
Out[78]:
<Axes: >
No description has been provided for this image
In [79]:
heart_disease_df.groupby(["gender"]).size().plot(kind='pie', y='gender', autopct='%1.0f%%')
Out[79]:
<Axes: >
No description has been provided for this image
In [80]:
hypertension_df.plot.hist(column=["age"], bins=80)
Out[80]:
<Axes: ylabel='Frequency'>
No description has been provided for this image
In [81]:
heart_disease_df.plot.hist(column=["age"], bins=80)
Out[81]:
<Axes: ylabel='Frequency'>
No description has been provided for this image
In [82]:
heart_disease_df.groupby(["work_type"]).size().plot(kind='pie', y='work_type', autopct='%1.2f%%')
Out[82]:
<Axes: >
No description has been provided for this image
In [83]:
hypertension_df.groupby(["work_type"]).size().plot(kind='pie', y='work_type', autopct='%1.2f%%')
Out[83]:
<Axes: >
No description has been provided for this image
In [84]:
df = data[['age', 'hypertension', 'heart_disease']].groupby(['age']).agg(
    hypertension=pd.NamedAgg(column="hypertension", aggfunc="sum"),
    heart_disease=pd.NamedAgg(column="heart_disease", aggfunc="sum")
)
plt.plot(df)
Out[84]:
[<matplotlib.lines.Line2D at 0x18576a5a450>,
 <matplotlib.lines.Line2D at 0x18576be13a0>]
No description has been provided for this image
In [84]:

In [84]: