Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何估算/准备此类时间序列数据?_Python_Pandas_Machine Learning_Time Series - Fatal编程技术网

Python 如何估算/准备此类时间序列数据?

Python 如何估算/准备此类时间序列数据?,python,pandas,machine-learning,time-series,Python,Pandas,Machine Learning,Time Series,我试图对时间序列数据进行分类,我们有n个徒步旅行者在两个地点之间旅行。我们只是试图对它们进行分类,而不考虑季节性 问题是,每个徒步旅行者在不同的日期开始和结束,其中一些人缺少时间戳,加上他们因任何原因(绕道、路径等)有不同的旅行时间。为方便起见,纬度和经度分别为l、lg n1 = [(l, lg, 04/08 00:00),(l, lg, 04/08 12:03),(l, lg, 04/09 02:30), (l, lg 04/10 00:05)...] n2 = [(l, lg

我试图对时间序列数据进行分类,我们有n个徒步旅行者在两个地点之间旅行。我们只是试图对它们进行分类,而不考虑季节性

问题是,每个徒步旅行者在不同的日期开始和结束,其中一些人缺少时间戳,加上他们因任何原因(绕道、路径等)有不同的旅行时间。为方便起见,纬度和经度分别为l、lg

    n1 = [(l, lg, 04/08 00:00),(l, lg, 04/08 12:03),(l, lg, 04/09 02:30), (l, lg 04/10 00:05)...]
    n2 = [(l, lg, 03/08 00:00),(l, lg, 03/09 03:03),(l, lg, 03/10 00:30), (l, lg 03/10 13:05)...]
    n3 = [(l, lg, 04/07 00:00),(l, lg, 04/08 03:03),(l, lg, 04/10 00:30), (l, lg 04/11 14:05)...]
    len(n1) == len(n2) != len(n3) #delayed due to detour
数据最可预测的规律性是,一天内发生的数据点不超过2个,因此

    nx = [(l, lg, 04/08 00:00),(l, lg, 04/08 10:00),(l, lg, 04/08 13:00)...]
永远不会发生

我正在考虑的是,忽略旅行的日期,只考虑时间的变化。这将消除开始日期差异:

    n1 = [(l, lg, 1),(l, lg, 2),(l, lg, 3), (l, lg, 5)...]
    n2 = [(l, lg, 1),(l, lg, 3),(l, lg, 5), (l, lg, 6)...]
    n3 = [(l, lg, 1),(l, lg, 3),(l, lg, 7), (l, lg, 10)...]
然后,对于缺少时间戳的行程,只需使用该点的平均lat/long或之前和之后数据的平均值进行插补

    n1 = [(l, lg, 1),(l, lg, 2),(l, lg, 3), (l,lg,4*), (l, lg, 5)...]
    n2 = [(l, lg, 1), (l,lg, 2*), (l, lg, 3),(l,lg,4*), (l, lg, 5)...]
    #timestamp* indicates imputed value
然后,我只需填充每个nx s.t.len(nx)==len(最长行程)。填充的值就是目的地的lat/long

      n_x = [...,(l, lg, 28),(dest_lat, dest_long,29),(dest_lat, dest_long, 30)]
      n_y = [...,(l, lg, 28),(l,lg, 29),(dest_lat, dest_long, 30)]
      #n_y is the longest trip, n_x has been padded s.t. len(n_x) == len(n_y)
我目前在熊猫数据框中有这些数据
df.columns=['ID'、'trip_points'、'trip_times']
(trip points=每次trip的lat和long元组列表),我正在试图找出如何实现我刚才描述的内容,或者看看是否有其他方法可以实现。 我绞尽脑汁,但就是不知道我是否错过了更好的解决方案