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

ENH (GH6568) Add option info_verbose #6890

Closed
wants to merge 3 commits 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
32 changes: 32 additions & 0 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1666,3 +1666,35 @@ columns of DataFrame objects are shown by default. If ``max_columns`` is set to
0 (the default, in fact), the library will attempt to fit the DataFrame's
string representation into the current terminal width, and defaulting to the
summary view otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add this same thing (you can copy-paste) to v0.14.0 as its a bit of a change, want to inform users, create a new sub-section (e.g. use ---- under the heading), put after the plotting sub-section (include a pointer to the basics section a ':ref:')

The visualization of a dataframe can be controled directly with two
options - `large_repr` and `info_verbose`. Depending on the size of
the DataFrame it might be more convenient to print a summary
representation only.

.. ipython:: python

df_lrge = DataFrame(columns=['a','b','c'],
index=DatetimeIndex(start='19900101',end='20000101',freq='BM'))

The default display for a DataFrame is 'truncate'. This prints all
elements of the df up to max_rows/max_columns.

.. ipython:: python

with option_context("display.large_repr",'truncate'):
print df_lrge

To get a more concise representation of the df

.. ipython:: python

with option_context("display.large_repr",'info'):
print df_lrge
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use print(df_lrge) (for py3 compat in doc building) instead of print


Further reduce summary view to one line for all columns

.. ipython:: python

with option_context("display.large_repr",'info',"display.info_verbose",False):
print df_lrge
5 changes: 5 additions & 0 deletions doc/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ As of 0.13, these are the relevant options, all under the `display` namespace,
- large_repr (default 'truncate'): when a :class:`~pandas.DataFrame`
exceeds max_columns or max_rows, it can be displayed either as a
truncated table or, with this set to 'info', as a short summary view.
- info_verbose (default True): When large_repr is set to 'info', the
index of a :class:`~pandas.DataFrame` will be displayed as a short
summary, while columns are still listed individually. When
'info_verbose' is set to False, the columns will be displayed in a
short summary view also.
- max_columns (default 20): max dataframe columns to display.
- max_rows (default 60): max dataframe rows display.
- show_dimensions (default True): controls the display of the row/col counts footer.
Expand Down
13 changes: 12 additions & 1 deletion pandas/core/config_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,17 @@
df.info() (the behaviour in earlier versions of pandas).
"""

pc_info_verbose_doc = """
: boolean

Relevant when `large_repr` set to `info`. Dictates whether a df
will be displayed as df.info(verbose=True) or
df.info(verbose=False). When `False`, columns are displayed in a
summary line, instead of listing all columns.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the default value?


pc_mpl_style_doc = """
: bool
: boolean

Setting this to 'default' will modify the rcParams used by matplotlib
to give plots a more pleasing visual style by default.
Expand Down Expand Up @@ -230,6 +239,8 @@ def mpl_style_cb(key):
validator=is_instance_factory([type(None), int]))
cf.register_option('large_repr', 'truncate', pc_large_repr_doc,
validator=is_one_of_factory(['truncate', 'info']))
cf.register_option('info_verbose', True, pc_info_verbose_doc,
validator=is_bool)
cf.register_option('max_info_columns', 100, pc_max_info_cols_doc,
validator=is_int)
cf.register_option('colheader_justify', 'right', colheader_justify_doc,
Expand Down
7 changes: 5 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,20 +1381,23 @@ def to_latex(self, buf=None, columns=None, col_space=None, colSpace=None,
if buf is None:
return formatter.buf.getvalue()

def info(self, verbose=True, buf=None, max_cols=None):
def info(self, verbose=None, buf=None, max_cols=None):
"""
Concise summary of a DataFrame.

Parameters
----------
verbose : boolean, default True
verbose : boolean, default None
If False, don't print column count summary
buf : writable buffer, defaults to sys.stdout
max_cols : int, default None
Determines whether full summary or short summary is printed
"""
from pandas.core.format import _put_lines

if verbose is None:
verbose = get_option("display.info_verbose")

if buf is None: # pragma: no cover
buf = sys.stdout

Expand Down