【发布时间】:2022-08-09 15:53:57
【问题描述】:
我有 2 个熊猫表 table_a 和 table_b 两个表都包含相同的列 ID 和 no_of_employee
我需要在我尝试以下语法的两个表上交叉
table_a[\'key\'] = 1
table_b[\'key\'] = 1
df_detail = pd.merge(table_a, table_b, on =\'key\').drop(\"key\", 1)
但它没有正常工作,因为下面的输出包含四列:
[\'ID_x\',\'no_of_employee_x\',\'ID_y\',\'no_of_employee_y\']
但我只需要下面给出的最终表中的 2 列:
Id 和 no_of_employee
什么是正确的语法?我试图找到但没有找到。
-
你在使用 pyspark 还是 pandas?
-
@samkart Pandas 我正在使用
-
看起来你不需要交叉连接,使用外连接
标签: pandas cross-join