code: def returns(prices, method='simple', periods=1, fill_method='pad', limit=None, freq=None):
      
      if method not in ('simple', 'compound', 'log'):
          raise ValueError("Invalid method type. Valid values are ('simple', 'compound')")
  
      if method == 'simple':
          return prices.pct_change(periods=periods, fill_method=fill_method, limit=limit, freq=freq)
      else:
          if freq is not None:
              raise NotImplementedError("TODO: implement this logic if needed")
  
          if isinstance(prices, pd.Series):
              if fill_method is None:
                  data = prices
              else:
                  data = prices.fillna(method=fill_method, limit=limit)
  
              data = np.log(data / data.shift(periods=periods))
              mask = pd.isnull(prices.values)
              np.putmask(data.values, mask, np.nan)
              return data
          else:
              return pd.DataFrame(
                  {name: returns(col, method, periods, fill_method, limit, freq) for name, col in prices.iteritems()},
                  columns=prices.columns,
                  index=prices.index)
docs: compute the returns for the specified prices.
       method: [simple,compound,log], compound is log