【发布时间】:2020-06-25 04:07:40
【问题描述】:
我有两个数据框,如下所示。 如果有人买东西,我们也可以推荐类似的产品。
df1 有一个每个人购买的物品列表。 df2 有推荐的附加产品。 比如“Gopu”买包子,那我要推荐“butter”和“jam”
如果没有 added_product 项目(来自 df2),则它不需要出现在输出中。对于(例如)“Gopu”购买了一个项目“饼干”,但没有从 df2 推荐的附加项目。因此它不会出现在输出表中。谢谢
左侧的简单 df1.df2 连接不适合我。
df1:
name product
Gopu biscuit
Gopu bun
Gopu ink
Aish ball
Aish doll
Aish bun
Aish ink
Colin bun
Colin handsanitize
Colin paper
df2:
product added-product
bun butter
bun jam
ink cloth
ink bib
paper pen
doll barbie
预期输出:
Name added-product
Gopu butter
Gopu jam
Gopu cloth
Gopu bib
Aish barbie
Aish butter
Aish jam
Aish cloth
Aish bib
Colin butter
Colin jam
Colin pen
谢谢。
【问题讨论】:
标签: python-3.x dataframe join pyspark