从.xlsx文件合并2个dataFrames

时间:2018-12-24 14:38:10

标签: pandas dataframe merge

我正在合并从.xlsx的文件加载的2个数据帧。

首次合并作品:

import pandas as pd
listOfCities = ["City1", "City2"]
city = pd.read_excel(listOfCities[0] + ".xlsx")
mainDataBase = pd.read_excel("dataBase.xlsx")
emptyCity = city[city["Id_building"].isna()]
merged = pd.merge(emptyCity, mainDataBase, on = ['City','Street','building_number'])

第二个没有:

city = pd.read_excel(listOfCities[1] + ".xlsx")
merged = pd.merge(emptyCity, mainDataBase, on = ['City','Street','building_number'])

怎么了? Excel文件是同一类型。 在第二次合并时比较复杂:

ValueError: You are trying to merge on int64 and object columns. If you wish 
to proceed you should use pd.concat

0 个答案:

没有答案