Numpy:保存时间序列数据
下面是6个位置网格的时间序列数据示例Numpy:保存时间序列数据,numpy,time-series,Numpy,Time Series,下面是6个位置网格的时间序列数据示例 timestamp = "2019-10-01" temp = np.array([(22.1, 22.2, 22.3), (22.4, 22.5, 22.6)]) rh = np.array([(50.1, 50.2, 50.3), (50.4, 50.5, 50.6)]) 可以使用np.savez()将其保存到文件中以供以后分析。从CSV的角度考虑,目标是在一个文件中有多个这样的行(“2019-10-01”、“2019-10-02”,等等)。因此,问题
timestamp = "2019-10-01"
temp = np.array([(22.1, 22.2, 22.3), (22.4, 22.5, 22.6)])
rh = np.array([(50.1, 50.2, 50.3), (50.4, 50.5, 50.6)])
可以使用
np.savez()
将其保存到文件中以供以后分析。从CSV的角度考虑,目标是在一个文件中有多个这样的行(“2019-10-01”、“2019-10-02”
,等等)。因此,问题是,如何存储Numpy数组时间序列数据?最好将日期存储为年、月和日,以匹配数据集。当您需要将其恢复为最新版本时,请使用join
import numpy as np
from numpy import savetxt
import sys
import pandas as pd
timestamp = "2019-10-01"
year ,month,day = timestamp.split('-')
date =np.array([( year ,month, day)])
temp = np.array([(22.1, 22.2, 22.3), (22.4, 22.5, 22.6)])
rh = np.array([(50.1, 50.2, 50.3), (50.4, 50.5, 50.6)])
a=date.astype(str)
for row in a:
x='-'.join(row)
print(x)
看到代码了吗?看到这个:谢谢,这给了我一个日期数组。关键是,时间戳(日期)数组的形状是
(X)
,而其余的数据变量的形状是(X,2,3)
,其中X是测量的数量。使用X=timestamp
作为X.month,X.year和X.day
你这是什么意思?只需将时间转换为date=np.array([(x.月,x.年,x.日)])