def to_dataframe(d, **kw):
import pandas<EOL>if pimms.is_itable(d): d = d.dataframe<EOL>if is_dataframe(d): return d if len(kw) == <NUM_LIT:0> else pandas.DataFrame(d, **kw)<EOL>if is_tuple(d) and len(d) == <NUM_LIT:2> and pimms.is_map(d[<NUM_LIT:1>]):<EOL><INDENT>try: return to_dataframe(d[<NUM_LIT:0>], **pimms.merge(d[<NUM_LIT:1>], kw))<EOL>except Exception: pass<EOL><DEDENT>try: return pandas.DataFrame(d, **kw)<EOL>except Exception: pass<EOL>try: return pandas.DataFrame.from_records(d, **kw)<EOL>except Exception: pass<EOL>try: return pandas.DataFrame.from_dict(d, **kw)<EOL>except Exception: pass<EOL>raise ValueError('<STR_LIT>' % d)<EOL>
to_dataframe(d) attempts to coerce the object d to a pandas DataFrame object. If d is a
  tuple of 2 items whose second argument is a dictionary, then the dictionary will be taken
  as arguments for the dataframe constructor. These arguments may alternately be given as
  standard keyword arguments.