Skip to content

DOC: add print statement in to_latex example #27789

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

The docstring of to_latext shows a small example (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_latex.html) as

>>> df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
...                    'mask': ['red', 'purple'],
...                    'weapon': ['sai', 'bo staff']})
>>> df.to_latex(index=False) # doctest: +NORMALIZE_WHITESPACE
'\\begin{tabular}{lll}\n\\toprule\n      name &    mask &    weapon
\\\\\n\\midrule\n   Raphael &     red &       sai \\\\\n Donatello &
 purple &  bo staff \\\\\n\\bottomrule\n\\end{tabular}\n'

I think it would be nice to also add a print statement like print(df.to_latex(index=False))(typically you want to be able to copy it to your tex file, and so you first need to print it to have something you can copy paste)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions