I am calculating the distance between two points using the Harvesine formula available under mpu.haversine_distance
.
If I give a single pair of coordinate below code works. But, if I pass 5K cordinates, it gives me an exception.
import mpu
data = pd.read_csv(r'C:\Users\DATA.csv')
mpu.haversine_distance((40.717006,73.956565),(40.7205817,-73.9623624))
print (mpu.haversine_distance((data.pickup_lat,data.pickup_lon),(data.dropoff_lat,data.dropoff_lon)))
Exception:
~\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mpu\__init__.py in haversine_distance(origin, destination)
190 lat1, lon1 = origin
191 lat2, lon2 = destination
--> 192 if not (-90.0 <= lat1 <= 90):
193 raise ValueError('lat1={:2.2f}, but must be in [-90,+90]'.format(lat1))
194 if not (-90.0 <= lat2 <= 90):
~\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
1550
1551 def __nonzero__(self):
-> 1552 raise ValueError(
1553 "The truth value of a {0} is ambiguous. "
1554 "Use a.empty, a.bool(), a.item(), a.any() or a.all().".format(
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
How to resolve this exception or ignore this this exception?