[Solved] Print message if a certain condition meet on a dataframe


import pandas as pd, numpy as np

# filter results by showing records that meet condition

# sample df
d = {'SBP': [111, 100], 'DBP': [81, 40], 'HEARTRATE':[1,50]}
df = pd.DataFrame(data=d)
df

# if an alert is found, prints alert, else normal
if len(df[(df[ 'SBP' ] > 110) & (df[ 'DBP' ] > 80) & (df[ 'HEARTRATE' ] < 100)]) >0:
    print('Alert')
else:
    print('Normal')

7

solved Print message if a certain condition meet on a dataframe