请帮我解决错误吗?以及如何将打印功能的输出保存到数据帧?
from haversine import haversine
import pandas as pd
dataframe = pd.read_csv("gpsdataedit.csv", delimiter = None)
dataset = dataframe.values
n = 0
c = 0
b = 1
a = dataset
for value in enumerate(dataset) :
c = c + 1
b = b +1
n = n + 1
distance = haversine(a[c], a[b]).km
print(distance)
追踪(最近的呼叫最后):
文件“/home/rr/PycharmProjects/GPS/trydistance.py”,第32行,< module>
距离=半影(a [c],a [b])。km
IndexError:索引151超出轴0的范围,大小为151
答案 0 :(得分:1)
IIUC,抛弃所有无关的指数。
for x, y in enumerate(zip(dataset, dataset[1:])):
distance = haversine(x, y).km
print(distance)