title: How to count concurrent events in a dataframe in one line?
body: <p>I have a dataset with phone calls. I want to count how many active calls there are for each record.
  I found this <a href="https://stackoverflow.com/questions/24745882/pandas-cumulative-sum-using-current-row-as-condition">question</a> but I'd like to avoid loops and functions.</p>
  
  <p>Each call has a <code>date</code>, a <code>start time</code> and a <code>end time</code>.</p>
  
  <p>The dataframe:</p>
  
  <pre><code>      start       end        date
  0  09:17:12  09:18:20  2016-08-10
  1  09:15:58  09:17:42  2016-08-11
  2  09:16:40  09:17:49  2016-08-11
  3  09:17:05  09:18:03  2016-08-11
  4  09:18:22  09:18:30  2016-08-11
  </code></pre>
  
  <p>What I want:</p>
  
  <pre><code>      start       end        date  activecalls
  0  09:17:12  09:18:20  2016-08-10            1
  1  09:15:58  09:17:42  2016-08-11            1
  2  09:16:40  09:17:49  2016-08-11            2
  3  09:17:05  09:18:03  2016-08-11            3
  4  09:18:22  09:18:30  2016-08-11            1
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>import pandas as pd
  
  df = pd.read_clipboard(sep='\s\s+')
  
  df['activecalls'] = df[(df['start'] &lt;= df.loc[df.index]['start']) &amp; \
                         (df['end'] &gt; df.loc[df.index]['start']) &amp; \
                         (df['date'] == df.loc[df.index]['date'])].count()
  
  print(df)
  </code></pre>
  
  <p>What I get:  </p>
  
  <pre><code>      start       end        date  activecalls
  0  09:17:12  09:18:20  2016-08-10          NaN
  1  09:15:58  09:17:42  2016-08-11          NaN
  2  09:16:40  09:17:49  2016-08-11          NaN
  3  09:17:05  09:18:03  2016-08-11          NaN
  4  09:18:22  09:18:30  2016-08-11          NaN
  </code></pre>