image_output_1.png
from IPython.display import display

import pandas as pd

csv_path = '/kaggle/input/heart-failure-prediction/heart.csv'
hrz = pd.read_csv(csv_path)

target = ['HeartDisease']
num_attribs = ['Age', 'RestingBP', 'Cholesterol', 'MaxHR', 'Oldpeak']
cat_nom_attribs = ['ChestPainType', 'RestingECG', 'ST_Slope']
cat_bin_attribs = ['Sex', 'FastingBS', 'ExerciseAngina']
cat_attribs = cat_nom_attribs + cat_bin_attribs

for attr in cat_attribs:
    display(hrz[[attr, 'HeartDisease']].groupby(attr, as_index=False).mean().sort_values(by='HeartDisease', ascending=False))