[英]Pandas merge returning empty dataframe
I am merging the following 2 dataframes on a common column: 我将以下2个数据框合并到一个公共列中:
URL for df_a: [https://www.dropbox.com/s/6rmymbpomp2b1nd/df_a.csv?dl=0][1]
URL for df_b: [https://www.dropbox.com/s/67713f3y8omvuru/df_b.csv?dl=0][1]
df_a的网址:
[https://www.dropbox.com/s/6rmymbpomp2b1nd/df_a.csv?dl=0][1]
df_b的网址: [https://www.dropbox.com/s/67713f3y8omvuru/df_b.csv?dl=0][1]
pandas.merge(df_a, df_b, on='County')
returns an empty dataframe, even though there are common county values in the 2 dataframes. 即使两个数据帧中都有常见的县值,也将返回一个空的数据帧。 any suggestions on what to do?
有什么建议做什么?
Your counties in df_b
all have trailing space. df_b
所有县都具有尾随空格。 You can correct this with 您可以使用
df_b.County = [c.strip() for c in df_b.County]
The merge works after this. 合并将在此之后进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.