Skip to content

Ignore terminal width when not running in an interactive shell #2241

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,14 @@ def _concat_compat(to_concat, axis=0):
else:
return np.concatenate(to_concat, axis=axis)

def in_interactive_session():
""" check if we're running in an interactive shell

returns True if running under python/ipython interactive shell
"""
import __main__ as main
return not hasattr(main, '__file__')

# Unicode consolidation
# ---------------------
#
Expand Down
6 changes: 4 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,15 @@ def _need_info_repr_(self):
else:
# save us
if (len(self.index) > max_rows or
len(self.columns) > terminal_width // 2):
(com.in_interactive_session() and
len(self.columns) > terminal_width // 2)):
return True
else:
buf = StringIO()
self.to_string(buf=buf)
value = buf.getvalue()
if max([len(l) for l in value.split('\n')]) > terminal_width:
if (max([len(l) for l in value.split('\n')]) > terminal_width and
com.in_interactive_session()):
return True
else:
return False
Expand Down