我有一些模拟结果,希望能将它们与我持有的特定坐标的静态信息进行配对。
我正在使用pandas,
结果
我该如何使用合并(merge)来实现这个功能?
我正在使用pandas,
key
数据框如下所示:Orig_lat Orig_lng Dest_lat Dest_lng Site Lane_1
51.4410925 -0.0913334 51.4431736 -0.0681643 6 E
51.4431736 -0.0681643 51.4410925 -0.0913334 6 W
51.6300955 -0.0781079 51.6489284 -0.0602954 7 N
51.648917 -0.0600521 51.6299841 -0.0779832 7 S
51.4648078 -0.301316 51.4573656 -0.3219232 9 S
51.4573656 -0.3219232 51.4649063 -0.3013827 9 N
51.412392 0.0743042 51.4088694 0.0800096 11 S
51.4088694 0.0800096 51.412392 0.0743042 11 N
51.4728599 -0.0235216 51.4804927 -0.0231821 14 N
结果
数据框
如下所示:distance duration duration_in_traffic Orig_lat Orig_lng Dest_lat Dest_lng
1456736402 1670 186 337 51.4431736 -0.0681643 51.4410925 -0.0913334
1456736416 508 73 73 51.4380877 -0.2131928 51.4417083 -0.2168077
1456736416 508 71 71 51.4417083 -0.2168077 51.4380877 -0.2131928
1456736417 578 83 82 51.5229177 -0.4402988 51.5180086 -0.4391647
1456736417 578 79 79 51.5180086 -0.4391647 51.5229177 -0.4402988
1456736417 894 148 155 51.489123 -0.3015009 51.4886771 -0.2894982
1456736418 894 170 163 51.4886771 -0.2894982 51.489123 -0.3015009
1456736418 410 88 88 51.5294107 0.107865 51.5296292 0.1019929
1456736418 410 91 90 51.5296292 0.1019929 51.5294107 0.107865
1456736419 821 90 102 51.6043935 -0.340337 51.6038698 -0.3521945
1456736419 821 96 121 51.6038698 -0.3521945 51.6043935 -0.340337
1456736419 263 48 47 51.3718957 -0.0471616 51.3741868 -0.0480754
1456736420 263 48 48 51.3741868 -0.0480754 51.3718957 -0.0471616
1456736421 426 59 58 51.5122705 -0.2177689 51.5086821 -0.2156843
1456736421 426 55 70 51.5086821 -0.2156843 51.5122705 -0.2177689
1456736421 471 57 57 51.3782746 -0.1864154 51.3800551 -0.1916053
我希望从关键字中提取Site
和Lane_1
列,并使用Orig_lat
,Orig_lng
,Dest_lat
和Dest_lng
将它们与results
数据框连接起来,结果如下:
distance duration duration_in_traffic Orig_lat Orig_lng Dest_lat Dest_lng, Site, Lane_1
1456736402 1670 186 337 51.4431736 -0.0681643 51.4410925 -0.0913334
1456736416 508 73 73 51.4380877 -0.2131928 51.4417083 -0.2168077 41 N
1456736416 508 71 71 51.4417083 -0.2168077 51.4380877 -0.2131928 41 S
1456736417 578 83 82 51.5229177 -0.4402988 51.5180086 -0.4391647 42 S
1456736417 578 79 79 51.5180086 -0.4391647 51.5229177 -0.4402988 42 N
1456736417 894 148 155 51.489123 -0.3015009 51.4886771 -0.2894982 43 E
1456736418 894 170 163 51.4886771 -0.2894982 51.489123 -0.3015009 43 W
1456736418 410 88 88 51.5294107 0.107865 51.5296292 0.1019929 45 W
1456736418 410 91 90 51.5296292 0.1019929 51.5294107 0.107865 45 E
1456736419 821 90 102 51.6043935 -0.340337 51.6038698 -0.3521945 46 W
1456736419 821 96 121 51.6038698 -0.3521945 51.6043935 -0.340337 46 E
1456736419 263 48 47 51.3718957 -0.0471616 51.3741868 -0.0480754 48 N
1456736420 263 48 48 51.3741868 -0.0480754 51.3718957 -0.0471616 48 S
1456736421 426 59 58 51.5122705 -0.2177689 51.5086821 -0.2156843 54 S
1456736421 426 55 70 51.5086821 -0.2156843 51.5122705 -0.2177689 54 N
1456736421 471 57 57 51.3782746 -0.1864154 51.3800551 -0.1916053 58 W
我该如何使用合并(merge)来实现这个功能?