我有一个一年的多元时间序列。每小时的度量。我想每 15 分钟对整个数据集取消采样并以某种方式插入值;所以我可以使用时间索引将它与另一个数据框连接起来。
按照这里的官方文档,在 Google 的 Colab 环境中,事情很混乱。看一看,
波纹管是原始数据框,上面是重新采样的数据框。我不知道新的价值来自什么。
我的索引包含重复项,并且是一个多级索引。我没有使用pandas parse_date,而是将列读取并重新组合成日期,然后将其重新设置为索引。看一看
import pandas as pd
climat = pd.read_csv('data_export_2019-02-16 (1).csv', delimiter=';', na_values='--') #, parse_dates=True, index_col = [2,1,0],
idx = pd.to_datetime(climat.Year.astype(str) + '-' + climat.Month.astype(str) + '-' + climat.Day.astype(str) + ' ' + climat.Hour.astype(str))
climat.set_index(idx, inplace=True)
climat.drop(['Year','Day', 'Month', 'Hour'], axis=1, inplace=True)
climat_ = climat.drop_duplicates()
upsampled = climat_[['TMP','WNDCHILL','DPT','WNDSPD','WNDGUST','HR','PRMSL','VISIBILITY','TCDC']].resample('15Min')
interpolated = upsampled.interpolate(method='spline', order=2)
正如你所看到的,我推开了这个: parse_dates=True, index_col = [2,1,0]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句