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
Running time is too long
no
Efficient algorithm
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 .