title: Apply a EWMA rolling window function in Pandas but avoid initial NAN values
body: <p>I have the following dataframe and subsequent EWMA function:</p>
  <pre><code>from functools import partial
  
  #Create DF
  d = {'Name': ['Jim', 'Jim','Jim','Jim','Jim','Jim','Jim','Jim',], 'col2': [5,5,5,5,5,5,5,5]}
  df1 = pd.DataFrame(data=d)
  
  
  #EWMA 5
  alpha = 1-np.log(2)/3 
  window5 = 5
  weights5 = list(reversed([(1-alpha)**n for n in range(window5)]))
  ewma5 = partial(np.average, weights=weights5)
  
  df1['Rolling5'] = df1.groupby('Name')['col2'].transform(lambda x: x.rolling(5).apply(ewma5))
  df1
  </code></pre>
  <p>Which results in:</p>
  <p><a href="https://i.stack.imgur.com/pznBZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pznBZ.png" alt="enter image description here" /></a></p>
  <p>I have a specified a rolling window of 5 but does anyone know how can I get the EWMA to calculate in the first to 4th Row even though there arent 5 values?</p>
  <p>EG for row 1, calculate for just row 1 (which would just be the same value) and then for row 2 it calculates the EWMA of rows 1 &amp; 2. Also open to more efficient ways of doing this!</p>
  <p>Thanks very much!</p>