title: calculate Exponential Moving Average with pandas
body: <p>I try to calculate ema with pandas but the result is not good.
  I try 2 techniques to calculate :</p>
  
  <p>The first technique is the panda's function <code>ewn</code>:</p>
  
  <pre><code>window = 100
  c = 2 / float(window + 1)
  df['100ema'] = df['close'].ewm(com=c).mean()
  </code></pre>
  
  <p>But the last result of this function gives. <code>2695.4</code> but the real result is <code>2656.2</code></p>
  
  <p>The second technique is</p>
  
  <pre><code>window = 100
  c = 2 / float(window + 1)
  df['100sma'] = df['close'].rolling(window).mean()
  df['100ema'] = (c * df['close']) + ((1 - c) * df['100sma'])
  </code></pre>
  
  <p>The result is <code>2649.1</code> it's closer than first technique but is always not good</p>
  
  <p>The sma function give the good result </p>
  
  <p>** EDIT  **</p>
  
  <p>The response is </p>
  
  <pre><code>df['100ema'] = pd.Series.ewm(df['close'], span=window).mean()
  </code></pre>