docs: def save_csv(filename, dat, index=False, **kw):
      '''
      save_csv(filename, d) writes a pandas dataframe d to a CSV file with the given name. If pandas
        cannot be loaded, then an error is raised. If d is not a dataframe, to_dataframe() is called
        on it.
  
      All optional arguments are passed along to the pandas.DataFrame.to_csv function.
      '''
      import pandas
      from neuropythy.util import to_dataframe
      d = to_dataframe(dat)
      if any(filename.endswith(s) for s in ('.gz', '.bz2', '.lzma')):
          with gzip.open(filename, 'wt', newlines='') as fl: d.to_csv(fl, index=index, **kw)
      else:
          with open(filename, 'wt') as fl: d.to_csv(fl, index=index, **kw)
      return dat