【发布时间】:2020-04-27 22:17:51
【问题描述】:
我有两个这样的 csv 文件:
文件1:
ID,Value
ID_15ab_type1,0
ID_15ab_type2,0
ID_19ac_type1,0
ID_19ac_type2,0
ID_26de_type1,1
ID_26de_type2,1
ID_45fe_type1,2
ID_45fe_type2,0
ID_88da_type1,0
ID_88da_type2,0
ID_45ff_type1,0
ID_45ff_type2,1
文件2:
ID,Label
ID_15ab,0
ID_26de,1
ID_45fe,0
我想保留第一个文件中的行,只保留 ID 与第二个 csv ID 中的行相似的行
输出应如下所示:
ID,Value
ID_15ab_type1,0
ID_15ab_type2,0
ID_26de_type1,1
ID_26de_type2,1
ID_45fe_type1,2
ID_45fe_type2,0
【问题讨论】:
-
到目前为止您尝试过什么?请edit你的python代码进入你的问题。
标签: python csv comparison