在手动输入中可以正常工作。如果在循环中应用相同的东西。我收到错误消息IndexError: single positional indexer is out-of-bounds
:
x="entry"
new=R_data[R_data['Critical Observation'].str.contains(x)]
# y="physical petty cash per system difference petty cash balance maintained real time basis postponement making entry updating system cause difference"
y=new['Critical Observation'].astype(str)
type(y)
match=re.search("(\w+) (\w+) (\w+) "+(str(x))+" (\w+) (\w+) (\w+)",y.iloc[0])
print(match.group(0))
for x in Dict["Key Words"].iloc[0:5]:
new=R_data[R_data['Critical Observation'].str.contains(x)]
y=new['Critical Observation'].astype(str)
match=re.search("(\w+) (\w+) (\w+) "+(str(x))+" (\w+) (\w+) (\w+)",y.iloc[0])
match.group(0)
我想要R_data['Critical Observation']
中每个关键字的三个单词之前和之后。