Skip to content

Commit

Permalink
BUG: allow users to set the max number of columns before per column i…
Browse files Browse the repository at this point in the history
…nfo is hidden away pandas-dev#2524
  • Loading branch information
changhiskhan committed Dec 14, 2012
1 parent 8d847fb commit b2d9d35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
columns that can fit on it.
"""

pc_max_info_cols_doc="""
: int
max_info_columns is used in DataFrame.info method to decide if
per column information will be printed.
"""

pc_nb_repr_h_doc="""
: boolean
When True (default), IPython notebook will use html representation for
Expand Down Expand Up @@ -122,6 +128,8 @@
cf.register_option('max_rows', 100, pc_max_rows_doc, validator=is_int)
cf.register_option('max_colwidth', 50, max_colwidth_doc, validator=is_int)
cf.register_option('max_columns', 20, pc_max_cols_doc, validator=is_int)
cf.register_option('max_info_columns', 100, pc_max_info_cols_doc,
validator=is_int)
cf.register_option('colheader_justify', 'right', colheader_justify_doc,
validator=is_text)
cf.register_option('notebook_repr_html', True, pc_nb_repr_h_doc,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ def info(self, verbose=True, buf=None):
cols = self.columns

# hack
if verbose and len(self.columns) < 100:
if verbose and len(self.columns) < get_option('print.max_info_columns'):
lines.append('Data columns:')
space = max([len(com.pprint_thing(k)) for k in self.columns]) + 4
counts = self.count()
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3975,6 +3975,19 @@ def test_info(self):
frame.info(verbose=False)
sys.stdout = sys.__stdout__

def test_info_wide(self):
from pandas import set_option, reset_option
io = StringIO()
df = DataFrame(np.random.randn(5, 100))
df.info(buf=io)
self.assert_(len(io.getvalue().splitlines()) == 4)

set_option('print.max_info_columns', 101)
io = StringIO()
df.info(buf=io)
self.assert_(len(io.getvalue().splitlines()) > 100)
reset_option('print.max_info_columns')

def test_info_duplicate_columns(self):
io = StringIO()

Expand Down

0 comments on commit b2d9d35

Please sign in to comment.