Skip to content

Introduce 'tidy_repr' for DataFrames #6938

Closed
@bjonen

Description

@bjonen

How about adding a tidy_repr similar to the one available for Series (https://github.com/pydata/pandas/blob/master/pandas/core/series.py#L845) to the possible ways of displaying a DataFrame. I find this view very convenient for displaying long series. Searching through past issues I couldn't find a discussion on why this representation is not used for DataFrames.

I know the default view has recently changed to truncate (#4886). What I find missing with the truncate view is the possibility to see where the index/columns end. However, I know this is a very subjective topic, so I'd simply like to propose to add this view as an option.

The code for the representation could look similar to this (ignoring the column representation for the moment).
...

df = pd.DataFrame(columns=['a','b','c'],
       index=pd.DatetimeIndex(start='19900101',end='20000101',freq='BM'))

print df.iloc[:10].__repr__() + '\n...\n' + df.iloc[-10:].__repr__()

...

This proposal is related to #6890.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestOutput-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions