无法使用经度和纬度信息计算距离?

时间:2019-06-27 10:53:40

标签: python-3.x

我有四列拾取经度,拾取纬度,下降经度,拾取经度。我对使用经度和纬度信息计算距离感兴趣。最后,我会找到距离。

import math
import geopy.distance
import pandas as pd

data = pd.read_csv("/home/Documents/trip_duration.csv")

pickup = data[data["pickup_longitude" [i]] - data["pickup_latitude" [j]]] 
dropoff = data[data["dropoff_longitude" [i]] - data["dropoff_latitude" [j]]

print (geopy.distance.geodesic(data[["pickup_longitude"[i]] - ["pickup_latitude"[j]]).miles)
print (geopy.distance.geodesic(data[["pickup_longitude"[i]] - ["pickup_latitude"[j]]).km)
print (geopy.distance.geodesic(data[["dropoff_longitude"[i]] - ["dropoff_latitude"[j]]).km)
print (geopy.distance.geodesic(data[["dropoff_longitude"[i]] - ["dropoff_latitude"[j]]).miles)



import math
import geopy.distance
import pandas as pd
import numpy as np
data = pd.read_csv("/home/likithreddy/Documents/analyticvidhya/ML/nyc_taxi_final-1560516233164/nyc_taxi_trip_duration.csv")

pickup = data[data["pickup_longitude" [i]] - data["pickup_latitude" [j]]] 
dropoff = data[data["dropoff_longitude" [i]] - data["dropoff_latitude" [j]]

print (geopy.distance.geodesic(data[["pickup_longitude"[i]] - ["pickup_latitude"[j]]).miles)
print (geopy.distance.geodesic(data[["pickup_longitude"[i]] - ["pickup_latitude"[j]]).km)
print (geopy.distance.geodesic(data[["dropoff_longitude"[i]] - ["dropoff_latitude"[j]]).km)
print (geopy.distance.geodesic(data[["dropoff_longitude"[i]] - ["dropoff_latitude"[j]]).miles)

更正我的代码,

对于每次观察,我期望以英里和Km为单位的距离。

错误:

  

python distance.py文件“ distance.py”,第10行       打印(geopy.distance.geodesic(data [[“ pickup_longitude” [i]]-[“ pickup_latitude” [j]])。英里           ^ SyntaxError:语法无效

0 个答案:

没有答案