【发布时间】:2019-08-19 09:59:08
【问题描述】:
我正在尝试使用新的词干字符串值重新分配系列中的列表值。但是,我不知道该怎么做。目前我正在制作一个新列表并附加新词干,但这只是将所有列表中的所有单词放在列表ns 中。我只想用新词干的项目更新当前列表。
words = data.String.apply(lambda x: word_tokenize(x))
ns =[]
#print(words)
for i in words:
for j in i:
ns.append(ps.stem(j))
例如,words=
0 [I, loved, dogs, because, they, are, cute, and...
1 [my, dog, is, looking, at, me, weird, maybe, c...
2 [I, think, I, look, like, a, cupacake, one, wi...
3 [do, you, want, to, be, a, snowman, no, thanks...
4 [hey, do, you, know, what, time, it, is, cooking,...
5 [dogs, are, so, awesome, dogs, are, so, awesome]
在通过 for 循环阻止单词之后,words 应该是这样的:
0 [I, love, dog, becaus, they, are, cute, and...
1 [my, dog, is, look, at, me, weird, maybe, c...
2 [I, think, I, look, like, a, cupacake, one, wi...
3 [do, you, want, to, be, a, snowman, no, thank...
4 [hey, do, you, know, what, time, it, is, cook,...
5 [dog, are, so, awesome, dog, are, so, awesome]
在:
print(type(words))
print(type(words[1]))
print(type(words[1][1]))
输出:
<class 'pandas.core.series.Series'>
<class 'list'>
<class 'str'>
有什么想法吗?
谢谢!
【问题讨论】: