我有熊猫的数据帧:
df.text[:3]
0 nena shot by me httptcodcrsfqyvh httpstcokxr...
1 full version of soulless httptcowfmcyyu
2 when youre having a good day but then get to w...
Name: text, dtype: object
基本上它只是一个系列的tweets文本。没别的了。在
^{pr2}$现在我想在这个系列中拆分单词。它可以很好地配合这个:
df.text.str.split('')
0 [nena shot by me httptcodcrsfqyvh httpstcokx...
1 [full version of soulless httptcowfmcyyu]
2 [when youre having a good day but then get to ...
但是id不能用于apply
方法:
df.text.apply(lambda x: x.split(' '))
并引发异常:AttributeError: 'float' object has no attribute 'split'
我做错了什么?为什么apply方法把这个int索引作为参数?在
如果我使用df.text.map(lambda x: x.split(' '))
也一样
UPD公司
df[df.text == np.nan].shape
(0, 13)
以及
df.text[:3]
0 nena shot by me httptcodcrsfqyvh httpstcokxr...
1 full version of soulless httptcowfmcyyu
2 when youre having a good day but then get to w...
工作正常:
df.text[:3].map(lambda x: x.split())
0 [nena, shot, by, me, httptcodcrsfqyvh, httpstc...
1 [full, version, of, soulless, httptcowfmcyyu]
2 [when, youre, having, a, good, day, but, then,...
Name: text, dtype: object
目前没有回答
相关问题 更多 >
编程相关推荐