【发布时间】:2013-03-22 21:00:59
【问题描述】:
我有以下 python pandas 时间序列
index = pandas.date_range('4/1/2012','9/30/2012', freq='M')
df = pandas.DataFrame(numpy.random.randn(len(index),1), index=index)
df =
2012-04-30 1.06
2012-05-31 0.82
2012-06-30 0.65
2012-07-31 1.12
2012-08-31 1.09
2012-09-30 0.65
然后我将频率从一个月改为两个月
df_new = df.resample('2M')
重采样函数从最早的日期开始到最后一个日期。我得到的输出如下:
df_new =
2012-04-30 ...
2012-06-30 ...
2012-08-31 ...
2012-10-30 ...
而我希望算法以相反的顺序重新采样。我想要这样的输出:
df_new =
2012-05-31 ...
2012-07-31 ...
2012-09-30 ...
谁能帮忙解决这个问题..提前谢谢
【问题讨论】: