我对熊猫很陌生,我很难解决这个问题:
我有一个医生活动的数据框架
pd0.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 14059 entries, 0 to 4418
Data columns (total 22 columns):
dossier 14059 non-null object
code_praticien 14059 non-null object
nom_praticien 14059 non-null object
code_anesthesiste 13128 non-null object
nom_anesthesiste 13128 non-null object
patient 14059 non-null object
sexe_patient 14059 non-null object
date_naiss_patient 14059 non-null datetime64[ns]
date 14059 non-null datetime64[ns]
heure 13842 non-null float64
ccam_ngap_diag 13852 non-null object
libelle 14059 non-null object
association 7682 non-null float64
modificateur1 11340 non-null object
modificateur2 1262 non-null object
modificateur3 8 non-null float64
modificateur4 0 non-null float64
montant_ccam 13684 non-null float64
montant_ngap 207 non-null float64
depassement 14049 non-null float64
total 13901 non-null float64
praticien 13128 non-null object
dtypes: datetime64[ns](2), float64(8), object(12)
memory usage: 2.8+ MB
两列分别包含外科医生代码(“code_Praticine”)和麻醉师代码(“code_anesthesiste”):
test = pd0[['code_praticien', 'code_anesthesiste']]
test
Out[65]:
code_praticien code_anesthesiste
0 BENY00 MORA01
1 BENY00 MORA01
2 BENY00 MORA01
3 BENY00 MORA01
4 BENY00 MORA01
... ... ...
4414 GAUD00 SAVO01
4415 SAVO01 SAVO01
4416 GAUD00 SAVO01
4417 GAUD00 SAVO01
4418 SAVO01 SAVO01
[14059 rows x 2 columns]
我正在尝试处理“外科医生”是麻醉师的情况(例如:疼痛控制程序)。 在这种情况下,我们有“麻醉师代码”NaN和“麻醉师代码”,这是麻醉师代码之一。 我创建了一个新的列'Anestesiste',当不为空时,该列将包含'code\u Anestesiste'或'code\u Praticin' 当“代码”为null()且“代码”为in([有效代码列表])时
test['anesthesiste'] = test.code_anesthesiste
test.loc[test.code_anesthesiste.isnull() & test.code_praticien.isin(['MORA01', 'SAVO01'])].anesthesiste = pd0.code_praticien
但我一直遇到这样的错误:“ValueError:无法从重复轴重新编制索引” 我在谷歌上搜索了“复制轴”,但不明白我的错误在哪里
我看了fillna()函数,但它似乎不够,因为我不想在“麻醉师”列中有外科医生的代码(有时外科医生在没有麻醉师的情况下工作,然后我有“麻醉师代码”, 但“行为守则”不是麻醉师的守则)
谢谢你的帮助
您可以在此处使用简单的应用程序:
用当前有效麻醉列表替换
['GAUD00','test']
相关问题 更多 >
编程相关推荐