BUG: fix max_columns=0, close #2856 by lodagro · Pull Request #2881 · pandas-dev/pandas (original) (raw)
We are clearly not in line on this, no problem we will converge :-)
The place were you disagree on me using line_width
is the scenario when the frame repr fits in the boundaries set by max_columns/max_rows. Even than it is still possible than an info repr is needed when expand_frame_repr=False and the frame repr exceeds line_width. I find i strange that you want to check on terminal_width in this scenario and limit the repr width to line_width. It could also be i completely misunderstand line_width
/ expand_frame_repr
.
IMO terminal_width and terminal_height should only be used when requested by the user (either by setting max_columns, max_rows to zero, maybe also for line_width=0). I see no need to overrule the result returned from get_terminal_size. Now this is done for the qtconsole, it seems you also want to add a detection/overruling if the notebook is used. Even with those two in place there are other scenarios when get_terminal_size will not give the expected result. Why not leave it up to the user if he/she wants to use it. In this branch terminal_width/terminal_size is only used when either max_columns or max_rows is set to zero (yes it can be cleaned up). This is user controlled and we probably need to document the limitations of doing so, but i would leave it up to the user to make an informed decision. For me there is no need for qtconsole/notebook detection/overruling.
We do need to handle interactive or not, since users complained about the repr info fallback when using pandas in non interactive mode, being it un-unix like. On master, not all repr info fallbacks are prevented, is that ok?
Yes, it was spaghetti and i made it even worse, that is for later let us first converge on the desired behavior.
By the way, df.to_string() has a line_width issue
(also on master), when it falls back to a multi-page view, the line_width is not always respected, in the two examples below i expect width to be maxed on line_width=80.
In [1]: import pandas as pd
In [2]: len(repr(pd.DataFrame(123456, range(5), range(15))).split('\n')[1]) Out[2]: 92
In [3]: pd.options.display.max_columns = 1000
In [4]: len(repr(pd.DataFrame(0, range(5), range(35))).split('\n')[1]) Out[4]: 104