for index, row in df2.iterrows():
min=10000000
for indexer, rows in df1.iterrows():
if abs(row['time']-rows['time'])<min:
min = abs(row['time']-rows['time'])
#storing the position
pos = indexer
df2.loc[index,'vel'] = df1['vel'][pos]
df2.loc[index,'yaw'] = df1['yaw'][pos]
2 回答
它可以在 iterrows() 函数的帮助下完成 .
这是代码:
first table creation :
second table creation :
storing the result 在df2本身:
创建笛卡尔积,然后进行过滤 -