Use BDay()
to get the business days in range.
from pandas.tseries.offsets import *
In [185]: s
Out[185]:
2011-01-01 -0.011629
2011-01-02 -0.089666
2011-01-03 -1.314430
2011-01-04 -1.867307
2011-01-05 0.779609
2011-01-06 0.588950
2011-01-07 -2.505803
2011-01-08 0.800262
2011-01-09 0.376406
2011-01-10 -0.469988
Freq: D
In [186]: s.asfreq(BDay())
Out[186]:
2011-01-03 -1.314430
2011-01-04 -1.867307
2011-01-05 0.779609
2011-01-06 0.588950
2011-01-07 -2.505803
2011-01-10 -0.469988
Freq: B
With slicing:
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.779609
2011-01-06 0.588950
2011-01-07 -2.505803
2011-01-08 0.800262
2011-01-09 0.376406
Freq: D
In [190]: s.ix[x:y].asfreq(BDay())
Out[190]:
2011-01-05 0.779609
2011-01-06 0.588950
2011-01-07 -2.505803
Freq: B
and count()
In [191]: s.ix[x:y].asfreq(BDay()).count()
Out[191]: 3
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…