我有一个氨基数据集,我仅要从中提取计算机科学术语,因此对于此任务,我必须将list1与之进行比较。
https://www.aminer.org/oag2019
list1 = [“文档类型”,“调查和概述”,“参考著作”,“一般会议记录”,“传记”,“一般文献”,“计算标准,RFC和指南”,“交叉计算工具”和技术',......]
list1的总数是ACM提供的2112个计算机科学术语。
我必须以[]形式在数据帧列中与之比较(字符串比较)list1的数据帧>
df_train14year ['keywords']。head()
0“核磁共振谱”,“质谱”,“纳米...1“ plk1”,“阳离子二烷基组氨酸”,“晶体”。2“案例控制”,“儿童”,“燃料”,“碳氢化合物”,“ ...3“ Ca2 +处理”,“ CaMKII”,“心肌细胞”,“续...4名称:关键字,dtype:对象
在数据框中的每个列表中,每个列表中最多有10个关键词,最小值(3),并且在数据框中有数百万条记录。
因此,如果两个列表中都匹配了3个以上的单词,则必须将每个关键字与原始list1进行比较,并使用这些值填充数据框,可能还需要子字符串匹配。
如何在python中以低效率的方式执行此任务,我所做的是通过for循环与每个关键字进行比较,而不是整个列表,并且其中有三个循环,因此效率低下。
# for i in range(5):
# df.loc[i] = ['<some value for first>','<some value for second>','<some value for third>']
count = 0;
i = 0;
for index, row in df_train14year.iterrows():
# print("index",index)
i=1+1;
# if(i==50):
# break
for outr in row['keywords'].split(","):
#print(count)
if (count>1):
# print("found1")
count = 0;
break;
for inr in computerList:
# outr= outr.replace("[","") # i skip the below three lines because i applied the pre- processing on data to remove the [] and "
# outr= outr.replace("]","")
outr= outr.replace('"',"")
#print("outr",outr,"inr",inr)
if outr in inr:
count = count+1
if (count>10):
#print("outr",outr,"inr",inr)
# print("found2")
# df12.loc[i] = [index,row['keywords']]
#df12.insert(index,"keywords",row['keywords'])
df14_4_match = df14_4_match.append({'abstract': row['abstract'],'keywords': row['keywords'],'title': row['title'],'year': row['year']}, ignore_index=True)
break;
# else:
# print('not found')```
我有一个氨基数据集,我仅要从中提取计算机科学术语,因此对于此任务,我必须将list1与之进行比较。 https://www.aminer.org/oag2019 list1 = ['document ...
kewwords = [数据帧中的[nmr光谱”,“质谱”,“ nanos”]行