【发布时间】:2018-07-21 07:29:55
【问题描述】:
我有一个像这样的 csv davaset,我对其进行地理编码并添加到长 lat 列中,它有这些列
现在我在网上下载了一个更新的房子,它有时会添加这样的新房子(我突出显示了错误的房子,它应该是它上面的那个对不起:) )
我想将两个数据集合并在一起并保留我的经度和纬度信息,并且只保留我拥有的列。我似乎无法弄清楚如何进行合并,所以我手动编写了这个 python,但它太慢了
for index, row in new_ppr.iterrows():
address= row['Address']
houses_in_district = MASTER_ppr.loc[MASTER_ppr['Address'] == address]
if len(houses_in_district >= 1):
x = houses_in_district.tail(1).index.item()
new_ppr.loc[index, 'Longitude'] = houses_in_district.loc[x,'Longitude']
new_ppr.loc[index, 'Latitude'] = houses_in_district.loc[x,'Latitude']
else:
new_ppr.loc[index, 'Longitude'] = ""
new_ppr.loc[index, 'Latitude'] = ""
【问题讨论】:
标签: python pandas merge concatenation