【发布时间】:2021-03-08 22:21:52
【问题描述】:
我有两个dataframe,分别命名为df1和df2,data dataframe的内容如下。
df1:
line_item_usage_account_id line_item_unblended_cost name
100000000001 12.05 account1
200000000001 52 account2
300000000003 12.03 account3
df2:
accountname accountproviderid clustername app_pmo app_costcenter line_item_unblended_cost
account1 100000000001 cluster1 111111 11111111 12.05
account2 200000000001 cluster2 222222 22222222 52
我需要将不在 df2.accountproviderid 中的 df1.line_item_usage_account_id 的 ID 添加到联接中,如下所示:
accountname accountproviderid clustername app_pmo app_costcenter line_item_unblended_cost
account1 100000000001 cluster1 111111 11111111 12.05
account2 200000000001 cluster2 222222 22222222 52
account3 300000000003 NA NA NA 12.03
df2.accountproviderid 中找不到来自 df1.line_item_usage_account_id 的 id “300000000003”,因此它已添加到新数据框中。
知道如何实现这一目标吗?感谢您的帮助。
【问题讨论】:
标签: python dataframe pyspark pyspark-dataframes