我正试图过滤tweet文本中的所有#关键字。我使用str.extractall()来提取所有带有#关键字的关键字。
这是我第一次使用pandas从tweetText中过滤关键字。输入、代码、预期输出和错误如下所示。
输入:userID,tweetText
01, home #sweet home
01, #happy #life
02, #world peace
03, #all are one
04, world tour
等等。。。总的数据文件是用GB大小的scraped tweets和其他几列组成的。但我只对两个专栏感兴趣。
代码:import re
import pandas as pd
data = pd.read_csv('Text.csv', index_col=0, header=None, names=['userID', 'tweetText'])
fout = data['tweetText'].str.extractall('#')
print fout
预期产量:userID,tweetText
01,#sweet
01,#happy
01,#life
02,#world
03,#all
错误:Traceback (most recent call last):
File "keyword_split.py", line 7, in
fout = data['tweetText'].str.extractall('#')
File &#