title: Extract Business Days in Time Series using Python/Pandas
body: <p>I am working with high frequency data in Time Series and <strong>I would like to get all the business days from my data</strong>. My data observations are separated by seconds, so there are 86400 seconds each day and my data set are spread over 31 days (so there are 2,678,400 observations!).</p>
  
  <p>Here is (part) of my data:</p>
  
  <pre><code>In[1]: ts
  Out[1]: 
  2013-01-01 00:00:00    0.480928
  2013-01-01 00:00:01    0.480928
  2013-01-01 00:00:02    0.483977
  2013-01-01 00:00:03    0.486725
  2013-01-01 00:00:04    0.486725
  ...
  2013-01-31 23:59:56    0.451630
  2013-01-31 23:59:57    0.451630
  2013-01-31 23:59:58    0.451630
  2013-01-31 23:59:59    0.454683
  Freq: S, Length: 2678400
  </code></pre>
  
  <p><strong>What I would like to do is to create a new time series which consists of the business days from this month, but I would like to have them with their corresponding data seconds.</strong>
  For example, if 2013-01-02 (WED) until 2013-01-04 (Fri) are the first business days of the first week in January, then:</p>
  
  <pre><code>2013-01-02 00:00:00    0.507477
  2013-01-02 00:00:01    0.501373
  ...
  2013-01-03 00:00:00    0.489778
  2013-01-03 00:00:01    0.489778
  ...
  2013-01-04 23:59:58    0.598115
  2013-01-04 23:59:59    0.598115
  Freq: S, Length: 259200
  </code></pre>
  
  <p>so it will exclude of course all the data on Sat 2013-01-05 and 2013-01-06 since these are the weekend days. 
  and so on...</p>
  
  <p>I tried to use some pandas built-in commands, but couldn't find the right one since they aggregate by day without taking into consideration that each day contains sub columns in them. That is, for each second there is a value and they should not be averaged, just grouped together to a new series..</p>
  
  <p>for example I tried:</p>
  
  <ol>
  <li><code>ts.asfreq(BDay())</code> --> finds the business day but averages over each day  </li>
  <li><code>ts.resample()</code> --> you must define 'how' (mean, max, min...)</li>
  <li><code>ts.groupby(lambda x : x.weekday)</code> --> not either!</li>
  <li><code>ts = pd.Series(df, index = pd.bdate_range(start = '2013/01/01 00:00:00', end =  '2013/01/31   23:59:59' , freq = 'S'))</code> 
   --> df since the original data is as DataFramem. 
   Using pd.bdate_range didn't help since df and index must be in the same dimension..</li>
  </ol>
  
  <p>I searched in pandas documentation, googled but could not find a clue...<br>
  Does anybody have an idea?</p>
  
  <p>I would really appreciate your help!</p>
  
  <p>Thanks!</p>
  
  <p>p.s
  I would rather not use loops for that, since my data set is very large...
  (I have also other months to analyse)</p>