code: def df_string(df, percentage_columns=(), format_map=None, **kwargs):
      
      formatters_map = {}
      for col, dtype in df.dtypes.iteritems():
          if col in percentage_columns:
              formatters_map[col] = '{:,.2f} %'.format
          elif dtype == 'float64':
              formatters_map[col] = '{:,.2f}'.format
      if format_map:
          for key in format_map:
              formatters_map[key] = format_map[key]
      return df.to_string(formatters=formatters_map, **kwargs)
docs: Return a nicely formatted string for the given dataframe.
  
      Arguments
      ---------
      df : pandas.DataFrame
          A dataframe object.
      percentage_columns : iterable
          A list of cloumn names to be displayed with a percentage sign.
  
      Returns
      -------
      str
          A nicely formatted string for the given dataframe.
  
      Example
      -------
      >>> import pandas as pd
      >>> df = pd.DataFrame([[8,'a'],[5,'b']],[1,2],['num', 'char'])
      >>> print(df_string(df))
         num char
      1    8    a
      2    5    b