Vielleicht wird dies Ihr (unser) Problem lösen.
import random
import pandas as pd
import numpy as np
heart_rate = [random.randrange(45, 125) for _ in range(500)]
blood_pressure_systolic = [random.randrange(140, 230) for _ in range(500)]
blood_pressure_dyastolic = [random.randrange(90, 140) for _ in range(500)]
temperature = [random.randrange(34, 42) for _ in range(500)]
respiratory_rate = [random.randrange(8, 35) for _ in range(500)]
pulse_oximetry = [random.randrange(95, 100) for _ in range(500)]
vitalsign = {
'heart rate' : heart_rate,
'systolic blood pressure' : blood_pressure_systolic,
'dyastolic blood pressure' : blood_pressure_dyastolic,
'temperature' : temperature,
'respiratory rate' : respiratory_rate,
'pulse oximetry' : pulse_oximetry
}
vitalsign_maxima = {
'heart rate' : (50,101),
'systolic blood pressure' : (140,160),
'dyastolic blood pressure' : (90,100),
'temperature' : (35,39),
'respiratory rate' : (11,19),
'pulse oximetry' : (95,100)
}
def is_vitalsign_excellent(name):
lower, upper = vitalsign_maxima[name]
return (lower < df[name]) & (df[name] < upper)
df = pd.DataFrame(vitalsign)
f = np.where(is_vitalsign_excellent('heart rate') &
is_vitalsign_excellent('systolic blood pressure') &
is_vitalsign_excellent('dyastolic blood pressure') &
is_vitalsign_excellent('temperature') &
is_vitalsign_excellent('respiratory rate') &
is_vitalsign_excellent('pulse oximetry'),"excellent", "critical")
Dieser sollte jetzt funktionieren.
Für diesen Code bekomme ich: Übelkeit. –
Wollen Sie ein bitweises '&' anstelle eines Booleschen 'und'? – James
'&' hat Vorrang und Sie haben einige Klammern vergessen. – Julien