pandas_时间序列

In [24]: pd.Series(range(1000), pd.date_range("20170101", periods=1000))
Out[24]:
2017-01-01 0
2017-01-02 1
2017-01-03 2
2017-01-04 3
2017-01-05 4
...
2019-09-23 995
2019-09-24 996
2019-09-25 997
2019-09-26 998
2019-09-27 999
Freq: D, Length: 1000, dtype: int64

  生成时间序列

生产的这个Serice 下有resample() 方法。 可以用以从新采样。  如果Service的index是DatetimeIndex序列的话。 可以时候  W H min A 等方式采样。就可以统计出以每星期 小时 分钟 年 为一组的数据出来()

In [30]: print(sr.resample("A").sum())
2017-12-31 66430
2018-12-31 199655
2019-12-31 233415
Freq: A-DEC, dtype: int64

猜你喜欢

转载自www.cnblogs.com/chengege/p/12590404.html