title: EWMA Volatility in Python - Avoiding loops
body: <p>I have a time series that looks like this (a slice):</p>
  
  <pre><code>Date         3         7           10
  2015-02-13   0.00021  -0.00078927  0.00407473
  2015-02-16   0.0      -0.00343163  0.0
  2015-02-17   0.0       0.0049406   0.00159753
  2015-02-18   0.00117  -0.00123565 -0.00031423
  2015-02-19   0.00091  -0.00253578 -0.00106207
  2015-02-20   0.00086   0.00113476  0.00612649
  2015-02-23  -0.0011   -0.00403307 -0.00030327
  2015-02-24  -0.00179   0.00043229  0.00275874
  2015-02-25   0.00035   0.00186069 -0.00076578
  2015-02-26  -0.00032  -0.01435613 -0.00147597
  2015-02-27  -0.00288  -0.0001786  -0.00295631
  </code></pre>
  
  <p>For calculating the EWMA Volatility, I implemented the following functions:</p>
  
  <pre><code>def CalculateEWMAVol (ReturnSeries, Lambda):   
      SampleSize = len(ReturnSeries)
      Average = ReturnSeries.mean()
  
      e = np.arange(SampleSize-1,-1,-1)
      r = np.repeat(Lambda,SampleSize)
      vecLambda = np.power(r,e)
  
      sxxewm = (np.power(ReturnSeries-Average,2)*vecLambda).sum()
      Vart = sxxewm/vecLambda.sum()
      EWMAVol = math.sqrt(Vart)
  
      return (EWMAVol)
  
  def CalculateVol (R, Lambda):
      Vol = pd.Series(index=R.columns)
      for facId in R.columns:
          Vol[facId] = CalculateEWMAVol(R[facId], Lambda)
  
      return (Vol)
  </code></pre>
  
  <p>The function works properly, but with a large time series the process gets slow because of the for loop.</p>
  
  <p>Is there another approach to calling this function over the series?</p>