【发布时间】:2021-06-02 21:11:30
【问题描述】:
我刚开始学习python。我有一个关于在 excel 中匹配我的数据集中的一些单词的问题。
words_list 包含一些我想在数据集中找到的单词。
words_list = ('tried','mobile','abc')
df 是从 excel 中提取的,并选取了一个列。
df =
0 to make it possible or easier for someone to do ...
1 unable to acquire a buffer item very likely ...
2 The organization has tried to make...
3 Broadway tried a variety of mobile Phone for the..
我想得到这样的结果:
'None',
'None',
'tried',
'tried','mobile'
我在木星上是这样尝试的:
list = [ ]
for word in df:
if any (aa in word for aa in words_List):
list.append(word)
else:
list.append('None')
print(list)
但结果会在df中显示整个句子
'None'
'None'
'The organization has tried to make...'
'Broadway tried a variety of mobile Phone for the..'
我可以只在单词列表中显示结果吗?
对不起我的英语和
谢谢大家
【问题讨论】:
-
您想要什么确切的输出格式?请准确书写
标签: python python-3.x list find