【发布时间】:2018-10-16 18:07:00
【问题描述】:
我正在尝试将 df1 的每一行与 df2 的每一行循环,并在 df1 中创建一个新的 col 并将最小值(所有值)存储在其中。
lat_sc= shopping_centers['lat']
long_sc= shopping_centers['lng']
for i, j in zip(lat_sc,long_sc):
for lat_real, long_real in zip(real_estate['lat'],real_estate['lng']):
euclid_dist.append( lat_real - i)
short_dist.append(min(euclid_dist))
euclid_dist = []
结果:
df1['shortest'] = min(df1['lat']- each lat of df2)
df1['nearest sc'] = 对应的sc_id
编辑以在 df1 中包含 sc_id
【问题讨论】:
标签: python list loops dataframe