Skip to content

BUG: wrong detection if truncated repr is needed #22984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorisvandenbossche opened this issue Oct 3, 2018 · 0 comments · Fixed by #22987
Closed

BUG: wrong detection if truncated repr is needed #22984

jorisvandenbossche opened this issue Oct 3, 2018 · 0 comments · Fixed by #22987
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@jorisvandenbossche
Copy link
Member

There seems to be a bug in the detection of when a DataFrame repr will not fit the console width.

Small example, the repr of a 7 column float dataframe is 72 characters wide:

In [10]: pd.DataFrame(np.random.randn(3, 7))
Out[10]: 
          0         1         2         3         4         5         6
0 -0.039631 -0.630607 -0.041318 -0.679839  0.257494 -0.608414  0.013959
1  0.976692  0.578279  0.712098  1.292541 -0.934307  0.522638 -0.584541
2 -1.218953  0.124633 -0.705128  0.376275  0.044354  0.166730  1.122929

However, in my default terminal of 80 characters wide, it is truncated:

In [1]: pd.io.formats.console.get_terminal_size()
Out[1]: os.terminal_size(columns=80, lines=24)

In [2]: pd.DataFrame(np.random.randn(3, 7))
Out[2]: 
          0         1         2    ...            4         5         6
0  0.332255  0.408991 -0.446875    ...     0.533822  0.128198  0.421326
1  0.335729 -0.889485  2.038889    ...    -0.263465  1.786649  1.190037
2  0.197376  1.742540 -1.259510    ...     0.643844  0.634065 -0.623578

[3 rows x 7 columns]

("funny" thing is that this truncated repr is actually exactly as wide as the non-truncated one ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant