重采样(反采样)在 Pandas 数据帧上产生不可预测的错误

姜黄_

我有一个一年的多元时间序列。每小时的度量。我想每 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章