使用
BDay()得到工作日的范围内。
from pandas.tseries.offsets import *In [185]: sOut[185]: 2011-01-01 -0.0116292011-01-02 -0.0896662011-01-03 -1.3144302011-01-04 -1.8673072011-01-05 0.7796092011-01-06 0.5889502011-01-07 -2.5058032011-01-08 0.8002622011-01-09 0.3764062011-01-10 -0.469988Freq: DIn [186]: s.asfreq(BDay())Out[186]: 2011-01-03 -1.3144302011-01-04 -1.8673072011-01-05 0.7796092011-01-06 0.5889502011-01-07 -2.5058032011-01-10 -0.469988Freq: B
带切片:
In [187]: x=datetime(2011, 1, 5)In [188]: y=datetime(2011, 1, 9)In [189]: s.ix[x:y]Out[189]: 2011-01-05 0.7796092011-01-06 0.5889502011-01-07 -2.5058032011-01-08 0.8002622011-01-09 0.376406Freq: DIn [190]: s.ix[x:y].asfreq(BDay())Out[190]: 2011-01-05 0.7796092011-01-06 0.5889502011-01-07 -2.505803Freq: B
和
count()
In [191]: s.ix[x:y].asfreq(BDay()).count()Out[191]: 3
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)