mlresearch.latex.export_longtable

mlresearch.latex.export_longtable(table, path=None, caption=None, label=None, index=True)[source]

Exports a pandas dataframe to LaTeX (longtable) format.

This function replaces df.to_latex when there are latex commands in the table. Requires \usepackage{booktabs} and \usepackage{longtable} in the LaTeX preamble.

Warning

Do not pass a table with column names, index names or values containing an underscore (“_”), as it will result in an error in LaTeX. If you wish to have underscores in the LaTeX table, add a backslash before the underscore.

Returns:
tex_tablestr or None

If path is None, returns the result as a string. Otherwise returns None.