Skip to content

ENH: Option to configure line wrapping for columns #59564

Open
@Nagidrop

Description

@Nagidrop

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

When having large enough display.max_colwidth value and a column contains cells with long data, other columns with shorter data will get their content (containing whitespaces) line-wrapped, even though there is plenty of space left and also a scrollbar to accommodate the large DataFrame width.

This can be reproduced using the snippet below:

import pandas as pd

pd.set_option('display.max_colwidth', None)  # None or a large enough value
df = pd.DataFrame({
    'column name': ['data0', 'data1'],
    'col2': ['0', 'a really longggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg string']
})
display(df)

image

I want to make the column name shown on 1 line, instead of being line-wrapped to 2 lines. There isn't limited space here so I think linewrapping is unnecessary for such short data. I have searched in Pandas "Options and Settings" page) and there is currently no option to configure this behaviour. I would be really grateful if this gets implemented.

Feature Description

Add a new option to configure linewrapping behaviour for columns, e.g. display.linewrap that accepts boolean values, True to enable linewrapping and False otherwise.

Alternative Solutions

None

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions