Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b2d9d35

Browse files
committedDec 14, 2012
BUG: allow users to set the max number of columns before per column info is hidden away #2524
1 parent 8d847fb commit b2d9d35

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
 

‎pandas/core/config_init.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
columns that can fit on it.
4646
"""
4747

48+
pc_max_info_cols_doc="""
49+
: int
50+
max_info_columns is used in DataFrame.info method to decide if
51+
per column information will be printed.
52+
"""
53+
4854
pc_nb_repr_h_doc="""
4955
: boolean
5056
When True (default), IPython notebook will use html representation for
@@ -122,6 +128,8 @@
122128
cf.register_option('max_rows', 100, pc_max_rows_doc, validator=is_int)
123129
cf.register_option('max_colwidth', 50, max_colwidth_doc, validator=is_int)
124130
cf.register_option('max_columns', 20, pc_max_cols_doc, validator=is_int)
131+
cf.register_option('max_info_columns', 100, pc_max_info_cols_doc,
132+
validator=is_int)
125133
cf.register_option('colheader_justify', 'right', colheader_justify_doc,
126134
validator=is_text)
127135
cf.register_option('notebook_repr_html', True, pc_nb_repr_h_doc,

‎pandas/core/frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ def info(self, verbose=True, buf=None):
15941594
cols = self.columns
15951595

15961596
# hack
1597-
if verbose and len(self.columns) < 100:
1597+
if verbose and len(self.columns) < get_option('print.max_info_columns'):
15981598
lines.append('Data columns:')
15991599
space = max([len(com.pprint_thing(k)) for k in self.columns]) + 4
16001600
counts = self.count()

‎pandas/tests/test_frame.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,6 +3975,19 @@ def test_info(self):
39753975
frame.info(verbose=False)
39763976
sys.stdout = sys.__stdout__
39773977

3978+
def test_info_wide(self):
3979+
from pandas import set_option, reset_option
3980+
io = StringIO()
3981+
df = DataFrame(np.random.randn(5, 100))
3982+
df.info(buf=io)
3983+
self.assert_(len(io.getvalue().splitlines()) == 4)
3984+
3985+
set_option('print.max_info_columns', 101)
3986+
io = StringIO()
3987+
df.info(buf=io)
3988+
self.assert_(len(io.getvalue().splitlines()) > 100)
3989+
reset_option('print.max_info_columns')
3990+
39783991
def test_info_duplicate_columns(self):
39793992
io = StringIO()
39803993

2 commit comments

Comments
 (2)

wesm commented on Dec 14, 2012

@wesm
Member

What do you think about adding an option to DataFrame.info instead? I guess making it configurable is good

changhiskhan commented on Dec 14, 2012

@changhiskhan
ContributorAuthor

done. enabled both. keyword overrides

Please sign in to comment.