【发布时间】:2020-07-30 18:36:22
【问题描述】:
我有 csv 文件,其中包含一般概念和相应的医学术语或短语。我怎样才能写一个循环,以便我可以将所有短语分组到它们对应的概念?我对python不是很有经验,所以我不确定如何编写循环。
id concept phrase
--------------------------------
1 general_history H&P
1 general_history history and physical
1 general_history history physical
2 clinic_history clinic history physical
2 clinic_history outpatient h p
3 discharge discharge summary
3 discharge DCS
对于相同的概念术语(或相同的 ID),我如何将短语附加到列表中以获得如下内容:
var = [[general_history, ['history and physical', history physical]],
[clinic_history, ['clinic history physical', 'outpatient h p']],
[discharge, ['discharge summary', 'DCS']]]
【问题讨论】:
标签: python for-loop nested-loops