程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Pandas calculates the distance between two longitudes and latitudes. The amount of data is too large, hundreds of millions of lines. Is there an efficient algorithm?

編輯:Python
The phenomenon and background of the problem

pandas Calculate the distance between two longitudes and latitudes , Using methods that can be found on the Internet , I haven't seen the progress for half a day

lon1, lat1, lon2, lat2 = map(np.radians, tt.tolist()) # haversine The formula dlon = lon2 - lon1dlat = lat2 - lat1a = np.sin(dlat / 2) ** 2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon / 2) ** 2c = 2 * a * np.sin(np.sqrt(a))r = 6371c * r * 1000
Operation results and error reporting contents

Running time is too long

My solution ideas and tried methods

no

What I want to achieve

Efficient algorithm




Take the answer :

Now that we have used the available methods, we can not reduce the operation time , It is no longer a problem of algorithm optimization , So your problem is that the computing performance of the machine is not enough .
If the computer's graphics card is good, it is recommended to use minpy Speed up the operation , If the computer graphics card is not good or there is no independent graphics card , It is recommended to apply for calculation .
notes :python There may not be any in computing speed C/C++ fast , You can try another language .



  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved