我有一个数据框df1,如下所示,它有一个标签列表。
tags
0 label
0 document
0 text
0 paper
0 poster
...
21600 wood
21600 hot tub
21600 tub
21600 terrace
21600 blossom
还有另一个数据框df2,它映射到 df 中存在的标签,映射到列名“name”。
name iab
0 abies Nature and Wildlife
1 absinthe Food & Drink
2 abyssinian Pets
3 accessories Style & Fashion
4 accessory Style & Fashion
... ... ... ... ...
1595 rows × 4 columns
本质上,这个想法是在 df2 中搜索与 df1 中的标签相对应的列“名称”以找到相应的“iab”映射并输出具有两列的 CSV - 标签及其对应的“iab”映射。
输出看起来像这样:
tags iab
0 label <corresponding iab mapping
to 'name' found in df2>
0 document
0 text
0 paper
0 poster
...
21600 wood
21600 hot tub
21600 tub
21600 terrace
21600 blossom
我需要帮助才能实现这一目标。先感谢您!
笔记:
我试过的是
df_iab[df_iab['name'].isin(df['image_CONTAINS_OBJECT'])]
但这只会将 df2 缩减为与“标签”匹配的“iab”,但不会真正执行搜索并映射找到的值。
慕侠2389804
慕码人2483693
相关分类