code: def ewma(series, beta, n_window):
      nobs = len(series)
      scalar = (1 - beta) / (1 + beta)
      ma = []
      k = np.arange(n_window, 0, -1)
      weights = np.r_[beta**k, 1, beta ** k[::-1]]
      for t in range(n_window, nobs - n_window):
          window = series.iloc[t - n_window : t + n_window + 1].values
          ma.append(scalar * np.sum(weights * window))
      return pd.Series(
          ma,
          name=series.name,
          index=series.iloc[n_window:-n_window].index,
      )
  
imports: import matplotlib.pyplot
  import numpy
  import pandas
  import statsmodels.api
  from pandas_datareader.data import DataReader
label_desc: Use image node_id 1 for calling a global function with example usage: ewma(series, beta, n_window) and returns: pd