# -*- coding:utf-8 -*-
"""
作者:sunli
日期:2022年05月10日16:13
"""
import numpy as np
import pandas as pd
path = 'D:/Fall_dataset/MobiAct_Dataset_v2.0/zhouqi/data/3_500.csv'
timestamp = 72
time = 100
data = pd.read_csv(path)
data = data.iloc[:, :3]
data1 = data.iloc[time + 1 - timestamp:time + 1, :]
data2 = data.iloc[time:time + timestamp, :]
vec1 = np.array(data1) # DataFrame装换为ndarray
vec2 = np.array(data2)
data1 = vec1.tolist() # ndarray转换为list
data2 = vec2.tolist()
distance_sum = 0
for i in range(timestamp):
vec1 = np.array(data1[i]) # list转换为ndarray
vec2 = np.array(data2[i])
distance = np.sqrt(np.sum(np.square(vec1 - vec2)))
distance_sum = distance_sum + distance
print(distance)
print(distance_sum)
print(distance_sum/timestamp)
|