code: def get_csv_stats(stats, recorded_cols=None):
      """
      Create a CSV buffer from the stats DataFrame.
  
      Parameters
      ----------
      path: str
      stats: list[Object]
      recorded_cols: list[str]
  
      Returns
      -------
  
      """
      df, columns = prepare_stats(stats, recorded_cols=recorded_cols)
  
      return df.to_csv(
          None,
          columns=columns,
          # encoding='utf-8',
          quoting=csv.QUOTE_NONNUMERIC,
      ).encode()
  
imports: import copy
  import csv
  import json
  import numbers
  import os
  import time
  import numpy
  import pandas
  from catalyst.assets._assets import TradingPair
  from catalyst.exchange.utils.exchange_utils import get_algo_folder
  from catalyst.utils.paths import data_root, ensure_directory
  from operator import itemgetter
label_desc: Use image node_id 9 for calling a global function with example usage: get_csv_stats(stats, recorded_cols) and returns: df