Skip to content

ENH: \centering option for DataFrame.to_latex() method #62733

@sykacek

Description

@sykacek

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

When exporting data frames to Latex, I would like an option to center the table using LaTex \centering command directly using .to_latex() method.

Feature Description

New .to_latex() parameter, eg. centering=

Alternative Solutions

Cycle through exported code and append \centering manually, e. g.

f = open(filename, 'w') f.write(df.to_latex(...)) f.close() table = '' with open(filename, 'r') as f:	while True:	line = f.readline()	if not line:	break	table += line	if 'begin{table}' in line:	table += '\\centering\n' f.close() f = open(filename, 'w') f.write(table) f.close() 

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions