根据种族、性别、血清肌酐、年龄计算eGFR

创建一个含变量race、sex、Scr(单位μmol/L)、age(年)的df

df = pd.DataFrame({ 'race': ['black', 'black', 'black', 'black', 'white', 'white', 'white', 'white'], 
                    'sex': ['female', 'female', 'male', 'male', 'female', 'female', 'male', 'male'],
                     'Scr': [50, 70, 75, 90, 40, 65, 80, 85], 
                     'age': [45, 50, 60, 55, 42, 47, 58, 51] })

# df为:
    race     sex  Scr  age
0  black  female   50   45
1  black  female   70   50
2  black    male   75   60
3  black    male   90   55
4  white  female   40   42
5  white  female   65   47
6  white    male   80   58
7  white    male   85   51

自定义根据种族、性别、血清肌酐、年龄来计算eGFR的函数

def eGFR(i):
    if i["race"]=="black":
        if i["sex"] =="female":
            if i["Scr"]<=62:
                return 166*(i["Scr"]/88.4/0.7)**(-0.329)*0.993**i["age"]
            else:
                return 166*(i["Scr"]/88.4/0.7)**(-1.209)*0.993**i["age"]
        else:
            if i["Scr"]<=80:
                return 163*(i["Scr"]/88.4/0.9)**(-0.411)*0.993**i["age"]
            else:
                return 163*(i["Scr"]/88.4/0.9)**(-1.209)*0.993**i["age"]
    else:
        if i["sex"] =="female":
            if i["Scr"]<=62:
                return 144*(i["Scr"]/88.4/0.7)**(-0.329)*0.993**i["age"]
            else:
                return 144*(i["Scr"]/88.4/0.7)**(-1.209)*0.993**i["age"]
        else:
            if i["Scr"]<=80:
                return 141*(i["Scr"]/88.4/0.9)**(-0.411)*0.993**i["age"]
            else:
                return 141*(i["Scr"]/88.4/0.9)**(-1.209)*0.993**i["age"]

计算eGFR

df['eGFR'] = df.apply(eGFR,axis=1)

# df为:
    race     sex  Scr  age        eGFR
0  black  female   50   45  129.802540
1  black  female   70   50  100.654061
2  black    male   75   60  109.566525
3  black    male   90   55   95.423878
4  white  female   40   42  123.757989
5  white  female   65   47   97.532474
6  white    male   80   58   93.603286
7  white    male   85   51   90.971067

参考文献

Levey AS, Stevens LA, Schmid CH, et al. A new equation to estimate glomerular filtration rate. Ann Intern Med. 2009;150(9):604-612. doi:10.7326/0003-4819-150-9-200905050-00006

你可能感兴趣的:(医学,pandas,python)