Skip to content

BUG: pandas.Categorical.__unicode__ does not respect console display width #15380

Closed
@wesm

Description

@wesm

Code Sample, a copy-pastable example if possible

ages = [20, 22, 25, 27, 21, 23, 37, 31, 61, 45, 41, 32]
bins = [18, 25, 35, 60, 100]
cats = pd.cut(ages, bins)
print(repr(cats))

Problem description

This outputs

[(18, 25], (18, 25], (18, 25], (25, 35], (18, 25], ..., (25, 35], (60, 100], (35, 60], (35, 60], (25, 35]]
Length: 12
Categories (4, object): [(18, 25] < (25, 35] < (35, 60] < (60, 100]]

The first line has 106 characters. This is a bad user experience for shell users with 80-character-wide terminals

Expected Output

in the first line

[(18, 25], (18, 25], (18, 25], (25, 35], (18, 25], ...,
 (25, 35], (60, 100], (35, 60], (35, 60], (25, 35]]

or

[(18, 25], (18, 25], (18, 25], ..., (35, 60], (35, 60], (25, 35]]

Output of pd.show_versions()

pandas 0.19.2

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