try working this into a lambda function. loop through dictionaries to separate your values. Assumes principal diagnosis is always single value, but can have 1 or more secondary.
data_dict = [{"icd10":"I611","icd10Name":"Intracerebral haemorrhage in hemisphere, cortical","diagType":"1","diagTypeName":"Principal Diagnosis"},{"icd10":"I10","icd10Name":"Essential (primary) hypertension","diagType":"2","diagTypeName":"Comorbidity (??????????????????????)"},{"icd10":"E789","icd10Name":"Disorder of lipoprotein metabolism,unspecified","diagType":"2","diagTypeName":"Comorbidity (??????????????????????)"}]
co_diag = []
for d in data_dict:
if 'Principal Diagnosis' in d.values():
pd = d['icd10']
else:
co_diag.append(d['icd10'])
co_diag_str = ', '.join(co_diag)
within the steps you should be able to write columns you need.
Output if the loop:
In [19]: co_diag_str
Out[19]: 'I10, E789'
In [20]: pd
Out[20]: 'I611'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…