码迷,mamicode.com
首页 > 其他好文 > 详细

pandas_时间序列

时间:2020-03-29 01:27:25      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:highlight   采样   index   type   生产   div   eric   生成   amp   

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

pandas_时间序列

标签:highlight   采样   index   type   生产   div   eric   生成   amp   

原文地址:https://www.cnblogs.com/chengege/p/12590404.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!