试图合并熊猫“表A”和“表B”中的两个数据框。“表A”有200K行,表B“有310K行。一旦合并,我希望“表A”的行保持200K。我试试使用左、右、外合并,由于某种原因,表 A 的行不会停留在 200K `
This is the table that I have and I'm trying to merge
table A
ID pass date Suitcase Layover
500 yes 2/22/2018 1 yes
501 no 2/23/2018 3 yes
502 yes 2/24/2018 5 yes
504 yes 2/25/2018 2 no
505 yes 2/26/2018 1 yes
506 no 2/27/2018 2 no
507 yes 2/28/2018 5 no
560 yes 3/15/2019 2 yes
Table B
ID time_travel country
500 4 USA
504 3 MEXICO
507 1 Canada
621 2 Australia
3345 3 South Africa
7755 2 France
3385 1 California
merging2 = pd.merge(table A,Table B, on=["id"],
how="left",indicator=True)
merging2.head()
``` the goal is to have the column ID stay at 200k and to have a table that
looks like this
id pass date Suitcase Layover time_travel country
500 yes 2/22/2018 1 yes 4 USA
501 no 2/23/2018 3 yes
502 yes 2/24/2018 5 yes
504 yes 2/25/2018 2 no 3 MEXICO
505 yes 2/26/2018 1 yes
506 no 2/27/2018 2 no
507 yes 2/28/2018 5 no Canada