158 KiB
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]:
In [79]:
heart_disease_df.groupby(["gender"]).size().plot(kind='pie', y='gender', autopct='%1.0f%%')
Out[79]:
In [80]:
hypertension_df.plot.hist(column=["age"], bins=80)
Out[80]:
In [81]:
heart_disease_df.plot.hist(column=["age"], bins=80)
Out[81]:
In [82]:
heart_disease_df.groupby(["work_type"]).size().plot(kind='pie', y='work_type', autopct='%1.2f%%')
Out[82]:
In [83]:
hypertension_df.groupby(["work_type"]).size().plot(kind='pie', y='work_type', autopct='%1.2f%%')
Out[83]:
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]:
In [84]:
In [84]: