我两周前开始学习,现在我有点卡住了。我有 2 个 TimeSeries,看起来像这样:
2011-01-09 00:00:00+00:00 7.430126
2011-01-09 01:00:00+00:00 6.793855
2011-01-09 02:00:00+00:00 6.675949
2011-01-09 03:00:00+00:00 6.756636
2011-01-09 04:00:00+00:00 6.875174
2011-01-09 05:00:00+00:00 5.432611
2011-01-09 06:00:00+00:00 6.059197
2011-01-09 21:00:00+00:00 5.338928
2011-01-09 22:00:00+00:00 5.259672
2011-01-09 23:00:00+00:00 5.247196
2011-01-10 00:00:00+00:00 5.889274
2011-01-10 01:00:00+00:00 6.133871
2011-01-10 02:00:00+00:00 6.111958
2011-01-10 03:00:00+00:00 5.873732
2011-01-10 04:00:00+00:00 5.627684
2011-01-10 05:00:00+00:00 5.265644
2011-01-10 06:00:00+00:00 5.505559
2011-01-10 21:00:00+00:00 3.835050
2011-01-10 22:00:00+00:00 3.879653
2011-01-10 23:00:00+00:00 4.034543
2011-01-11 00:00:00+00:00 4.844272
2011-01-11 01:00:00+00:00 4.670967
2011-01-11 02:00:00+00:00 4.584164
2011-01-11 03:00:00+00:00 4.786821
这是风速测量的数据,我想将其与模型数据进行比较。更具体地说,我想比较夜间(21.00 - 6.00)的风速。所以我定义了一个函数:
def func(model, measure):
return (model-measure).mean()
此外,我在数据上创建了一个循环:
mean_night = []
start = 7
for a in night:
mean_night.append(func(model, measure[start:(start+10)]))
start = start+11
if start>5378:
break
问题是我丢失了时间索引并且丢失了一些数据(例如 1 天或 1 周),所以我在使用 DateRange 重新索引它时遇到了麻烦。最后,它应该如下所示:
date difference_means
2011-01-09 diff_1
2011-01-09 diff_2
等等。我使用熊猫 0.7.1。谢谢你的支持!(对不起我的英语不好:P)