title: Using latest panda APIs to compute exponential moving average
body: <p>I have a python v3.6 function using panda to compute exponential moving average of a list containing floating numbers. Here is the function and it is tested to work;</p>
  
  <pre><code>def get_moving_average(values, period):
      import pandas as pd
      import numpy as np
  
      values = np.array(values)
      moving_average = pd.ewma(values, span=period)[-1]
      return moving_average
  </code></pre>
  
  <p>However, <code>pd.ewma</code> is a deprecated function and although it still works, I would like to use the latest API to use panda the correct way.</p>
  
  <p>Here is the documentation for the latest exponential moving average API.</p>
  
  <p><a href="http://pandas.pydata.org/pandas-docs/stable/api.html#exponentially-weighted-moving-window-functions" rel="nofollow noreferrer">http://pandas.pydata.org/pandas-docs/stable/api.html#exponentially-weighted-moving-window-functions</a></p>
  
  <p>I modified the original function into this to use the latest API;</p>
  
  <pre><code>def get_moving_average(values, period, type="exponential"):
      import pandas as pd
      import numpy as np
  
      values = np.array(values)
      moving_average = 0
      moving_average = pd.ewm.mean(values, span=period)[-1]
      return moving_average
  </code></pre>
  
  <p>Unfortunately, I got the error <code>AttributeError: module 'pandas' has no attribute 'EWM'</code></p>