我正在尝试获取代码以检查是否有名称,例如数据框一栏中的“哈利·波特”与商品标题“哈利·波特T恤”相匹配,这样我就可以返回商品标题字典以及我从名称中为每个商品生成的标签,例如“ {哈利·波特T-衬衫:哈利·波特,...}'。计划是将for循环的结果首先添加到两个列表中,然后将其压缩到dict。
这是我所做的,但是输出列表返回一些奇怪的东西:
title_list = []
tag_list = []
for title in en_df['title']:
for name in anime_dict['En']:
if name in title:
title_list.append(title)
tag_list.append(name)
tag_list
Output:
['-',
'-',
'-',
.
.
.
'-']
en_df['title'] //column holding all the item titles e.g. Harry Potter T-shirt
anime_dict['En'] // column holding all the names e.g. Harry Potter
不胜感激!