我在我的“sp500news3”上运行以下命令,它返回一个None值
def extract_ticker(title):
for word in title:
if word in constituents['Symbol']:
return word
sp500news3['tickers'] = sp500news3['title'].apply(extract_ticker)
#sp500news3 sample:
index date_publish title tickers
0 79944 2007-01-29 19:08:35 (MSFT, Vista, corporate, sales, go, very, well) None
1 181781 2007-12-14 19:39:06 (WMB, No, Anglican, consensus, on, Episcopal, Church) None
2 213175 2008-01-22 11:17:19 (CSX, quarterly, profit, rises) None
3 93554 2008-01-22 18:52:56 (C, says, 30, bln, capital, helps, exceed, target) None
成分['Symbol']:样品
0 TWX
1 C
2 MSFT
3 WMB ...
从以下位置复制spacy文档:
constituents = pd.DataFrame({"Symbol":["TWX","C","MSFT","WMB"]})
sp500news3 = pd.DataFrame({"title":["MSFT Vista corporate sales go very well","WMB No Anglican consensus on Episcopal Church","CSX quarterly profit rises",'C says 30 bln capital helps exceed target','TWX plans cable spinoff']})
import spacy
nlp = spacy.load('en_core_web_sm')
sp500news3['title'] = sp500news3['title'].apply(nlp)
必须使用} 在^{} which doesn't implement ^{} for strings 上迭代时:
word.text
,因为iterating over a ^{以您的例子:
相关问题 更多 >
编程相关推荐