code: def calc_stats(prices):
      
      if isinstance(prices, pd.Series):
          return PerformanceStats(prices)
      elif isinstance(prices, pd.DataFrame):
          return GroupStats(*[prices[x] for x in prices.columns])
      else:
          raise NotImplementedError('Unsupported type')
docs: Calculates performance stats of a given object.
  
      If object is Series, a PerformanceStats object is
      returned. If object is DataFrame, a GroupStats object
      is returned.
  
      Args:
          * prices (Series, DataFrame): Set of prices