def table(ax, data, rowLabels=None, colLabels=None, **kwargs):
if isinstance(data, ABCSeries):<EOL><INDENT>data = data.to_frame()<EOL><DEDENT>elif isinstance(data, ABCDataFrame):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if rowLabels is None:<EOL><INDENT>rowLabels = data.index<EOL><DEDENT>if colLabels is None:<EOL><INDENT>colLabels = data.columns<EOL><DEDENT>cellText = data.values<EOL>import matplotlib.table<EOL>table = matplotlib.table.table(ax, cellText=cellText,<EOL>rowLabels=rowLabels,<EOL>colLabels=colLabels, **kwargs)<EOL>return table<EOL>
Helper function to convert DataFrame and Series to matplotlib.table

Parameters
----------
ax : Matplotlib axes object
data : DataFrame or Series
    data for table contents
kwargs : keywords, optional
    keyword arguments which passed to matplotlib.table.table.
    If `rowLabels` or `colLabels` is not specified, data index or column
    name will be used.

Returns
-------
matplotlib table object