【发布时间】:2017-07-13 05:01:38
【问题描述】:
我有以下两个功能:
#To update the label1 if word is present with is_name
def update(data,word_lists, is_name):
for wlist in word_lists:
if check_keywords(data, wlist):
return is_name
return ''
#To check if Words are present in my Short_description field.
def check_keywords(data, words):
cnt=0
for word in words:
if word in data:
cnt+=1
return cnt==len(words)
以下是我的数据格式:
Short_description, label1
这些是我的数据 ACE_2017 中的列。 我需要检查 Short_description 中的关键字并更新 label1
下面是我的更新命令:
#To check if "access request" or "request Access" is present in Short_description then it should update label1 with 'Access request'
ACE_2017.ix[ACE_2017['label1']=='','label1'] = ACE_2017[ACE_2017['label1']==''].Short_description.map(lambda x: update(x,[['access request','request Access']],'Access request'))
但是当我运行上面的命令时它说
“NoneType”类型的参数不可迭代
我在这里缺少什么,我该如何解决这个问题。
【问题讨论】:
-
我写了一个答案,但它也有助于了解你想要做什么
-
用数据及其目的更新了我的问题