【发布时间】:2021-09-16 13:06:39
【问题描述】:
我有三个数据集:
数据集 1
Customer1 Customer2 Exposures + other columns
Nick McKenzie Christopher Mill 23450
Nick McKenzie Stephen Green 23450
Johnny Craston Mary Shane 12
Johnny Craston Stephen Green 12
Molly John Casey Step 1000021
dataset2(唯一客户:客户 1 + 客户 2)
Customer Age
Nick McKenzie 53
Johnny Craston 75
Molly John 34
Christopher Mill 63
Stephen Green 65
Mary Shane 54
Casey Step 34
Mick Sale
数据集 3
Customer1 Customer2 Exposures + other columns
Mick Sale Johnny Craston
Mick Sale Stephen Green
风险仅针对客户 1。
为简洁起见,省略了其他列。数据集 2 是通过获取唯一客户 1 和唯一客户 2 构建的:该数据集中没有重复项。数据集 3 与数据集 1 具有相同的列。
我想将数据集 1 中的信息添加到数据集 2 中
最终数据集
Customer Age Exposures + other columns
Nick McKenzie 53 23450
Johnny Craston 75 12
Molly John 34 1000021
Christopher Mill 63
Stephen Green 65
Mary Shane 54
Casey Step 34
Mick Sale
最终的数据集应该包含数据集 1 和数据集 3 中的所有 Customer1 和 Customer 2,并且没有重复。 我尝试将它们组合如下
result = pd.concat([df2,df1,df3], axis=1)
但结果不是我所期望的。 我连接数据集的方式出了点问题,如果您能告诉我出了什么问题,我将不胜感激。
【问题讨论】:
-
不幸的是,这个问题没有任何可行的解决方案就关闭了。