title: How to speed up/parallelize repeated df.between_time() calls occurring for each row in df?
body: <p>Setup: Anaconda running Python 3.5, Pandas</p>
  
  <p>I have a dataframe that is multiindex with indexes (datetime, id#) columns (p1,p2,p3...). </p>
  
  <p>I need to calculate the 10 minute average across days of the columns, so I'm using the .between_time() method with a list comprehension. </p>
  
  <pre class="lang-py prettyprint-override"><code>df['time_mean']=[df.xs(ID.value).between_time(((df.xs(ID.value)['p1_datetime'][rows])-datetime.timedelta(minutes=5)).time().strftime("%H:%M:%S"),((df.xs(ID.value)['p1_datetime'][rows])+datetime.timedelta(minutes=5)).time().strftime("%H:%M:%S"))['p1'].mean() for rows, x in enumerate(df['p1'])]
  </code></pre>
  
  <p>Each ID# is a device that can be started at an arbitrary time, so they are not synchronized. </p>
  
  <p>Since each .between_time() call is only a read/scan of df and isn't dependent, can I further parallelize it.</p>
  
  <p>My understanding is that a list comprehension will be as fast or faster than map(), but can I somehow farm out each iteration of the list comprehension to a different thread?</p>