我无法将以下内容应用到我的系列中。
Data['Notes']
0 2018-06-07 09:38:14Z -- legal -- As per ...
1 2018-06-05 12:48:26Z -- name -- Holdin...
2 2018-06-05 17:15:48Z -- filing -- Answe...
3 2018-06-11 08:34:53Z -- name -- lvm i...
4 2018-05-11 08:31:26Z -- filed -- summo...
5 2018-06-01 16:07:11Z -- Name Rogers -- sent ...
import re
keywords = {'file', 'filing', 'legal'}
max_words_after = 5
key_re = re.compile(fr"""
(?:{'|'.join([w for w in keywords])}) #keyword options group
\s((?:[\s]?[A-Za-z\']+[\s]?) #capture word. include with line-breaks
{{1,{max_words_after}}}) #1 to max_words_after
""", re.VERBOSE|re.IGNORECASE
)
data['Result'] = pd.Series
def word_search(series):
return key_re.findall(series)
data['Result'] = data.apply(word_search(data['Notes']))
TypeError Traceback (most recent call last)
<ipython-input-32-e6b6bcbe720d> in <module>()
13 def word_search(series):
14 return key_re.findall(series)
---> 15 data['Result'] = data.apply(word_search(data['Notes']))
16
17
<ipython-input-32-e6b6bcbe720d> in word_search(series)
12 data['Result'] = pd.Series
13 def word_search(series):
---> 14 return key_re.findall(series)
15 data['Result'] = data.apply(word_search(data['Notes']))
16
TypeError: expected string or bytes-like object
请告诉我如何获得每个索引位置的结果并将其附加到数据框中的新系列。