Skip to content
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

Closed
dandavison opened this issue Jul 12, 2012 · 8 comments
Closed

Console-width detection should be interactive sessions only #1610

dandavison opened this issue Jul 12, 2012 · 8 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@dandavison
Copy link

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

@lodagro
Copy link
Contributor

lodagro commented Jul 12, 2012

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?

@dandavison
Copy link
Author

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. (ls is a well-known exception.)

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 ls .)

@lodagro
Copy link
Contributor

lodagro commented Jul 12, 2012

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.

@dandavison
Copy link
Author

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.)

@lodagro
Copy link
Contributor

lodagro commented Jul 12, 2012

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.

@dandavison
Copy link
Author

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.

wesm pushed a commit that referenced this issue Nov 14, 2012
…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.
@ghost
Copy link

ghost commented Nov 14, 2012

close?

@wesm
Copy link
Member

wesm commented Nov 14, 2012

yep

@wesm wesm closed this as completed Nov 14, 2012
yarikoptic added a commit to neurodebian/pandas that referenced this issue Nov 15, 2012
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

3 participants