简体   繁体   中英

Python Pandas merging 2 tables with inner join:

Hi I am merging two tables with an inner join using pandas but I am getting a weird output. Below I am pasting the two tables: 在此处输入图像描述

在此处输入图像描述

I want to inner join the tables so it only shows the zipcodes in the df2 table so I use this line:
result = pd.merge(ppy, df2, how="inner", on=["zipcode"])

But now I am getting two records for each zipcode

在此处输入图像描述

Anyone have any idea on how to fix this or what might be causing this issue?

The data types of zipcode variables in datasets can be different. Check it with the dtype () method. If the data types are different, you can combine them and combine them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM