code: def mavg(data, xseq, **params):
      
      window = params['method_args']['window']
  
      # The first average comes after the full window size
      # has been swept over
      rolling = data['y'].rolling(**params['method_args'])
      y = rolling.mean()[window:]
      n = len(data)
      stderr = rolling.std()[window:]
      x = data['x'][window:]
      data = pd.DataFrame({'x': x, 'y': y})
      data.reset_index(inplace=True, drop=True)
  
      if params['se']:
          df = n - window  # Original - Used
          data['ymin'], data['ymax'] = tdist_ci(
              y, df, stderr, params['level'])
          data['se'] = stderr
  
      return data
docs: Fit moving average