-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
Console-width detection should be interactive sessions only #1610
Comments
Auto detection of the terminal width is a print option set by default. It can be disabled by setting max_columns to a non zero value. pandas.set_printoptions(max_columns=10) Idea behind the auto detection is to determine if the full string representation of a series or dataframe fits in the terminal (either in width/height or both). If it does not fit a summary view will be displayed. Fit or not is independent if you run from interactive shell or not, so why ignore it? |
What I'm saying is basically that it is un-UNIXy for the stdout of a shell command to depend on the dimensions of the terminal. ( In fact I think there is one clear argument that there is a bug here: the behavior persists even when redirecting the stdout to a file. That should definitely not happen by default; when redirecting stdout to a file, the resulting contents of that file should not depend on current terminal dimensions. (That's true even for |
Indeed, by default pandas always checks terminal width, which impacts output. However user/user-code is in full control and can change this behavior if desired, potentially based on interactive/non interactive use. |
Right. I propose changing the default so that non-interactive use does not check terminal width. (I don't propose making it impossible for users to have terminal-width-detection in non-interactive mode.) |
What i meant by user/user-code is in full control is that you can determine in your script/code when you want to use or disable auto detect of terminal width. Without changing pandas internals you can have the desired behavior. |
Right, but I am saying that the pandas default is wrong: by default, without having to change any options, output to file from a python program should not depend on terminal width. So a code change to pandas would be required to fix that. |
…actively. #1610 WARNING: nose runs non-interactively, so this is potential heisenbug material. but no changes to the test suite were needed, so I hope we're okay.
close? |
yep |
Version 0.9.1 * tag 'v0.9.1': RLS: Version 0.9.1 final BUG: icol() should propegate fill_value for sparse data frames pandas-dev#2249 TST: icol() should propegate fill_value for sparse data frames BUG: override SparseDataFrame.icol to use __getitem__ instead of accessing _data internals. close pandas-dev#2251 BUG: make Series.tz_localize work with length-0 non-DatetimeIndex. close pandas-dev#2248 BUG: parallel_coordinates bugfix with matplotlib 1.2.0. close pandas-dev#2237 BUG: issue constructing DataFrame from empty Series with name. close pandas-dev#2234 ENH: disable repr dependence on terminal width when running non-interactively. pandas-dev#1610 BUG: ExcelWriter raises exception on PeriodIndex pandas-dev#2240 BUG: SparseDataFrame.icol return SparseSeries. SparseSeries.from_array return SparseSeries. close pandas-dev#2227, pandas-dev#2229 BUG: fix tz-aware resampling issue. close pandas-dev#2245
I was surprised to see that my program's standard output changed when I unplugged my laptop from my external display this afternoon! I suggest that the terminal-width detection feature should only operate in an interactive python session. In non-interactive usage the stdout should depend only on the print options currently in effect.
See PR #453
The text was updated successfully, but these errors were encountered: