Skip to content

Commit 2e4ca43

Browse files
author
y-p
committed
Merge pull request #5550 from takluyver/long-repr-html
HTML reprs for large dataframes.
2 parents 6705b1e + 03a81c5 commit 2e4ca43

File tree

9 files changed

+370
-175
lines changed

9 files changed

+370
-175
lines changed

doc/source/dsintro.rst

+6-15
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,9 @@ indexing semantics are quite different in places from a matrix.
573573
Console display
574574
~~~~~~~~~~~~~~~
575575

576-
For very large DataFrame objects, only a summary will be printed to the console
577-
(here I am reading a CSV version of the **baseball** dataset from the **plyr**
576+
Very large DataFrames will be truncated to display them in the console.
577+
You can also get a summary using :meth:`~pandas.DataFrame.info`.
578+
(Here I am reading a CSV version of the **baseball** dataset from the **plyr**
578579
R package):
579580

580581
.. ipython:: python
@@ -587,6 +588,7 @@ R package):
587588
588589
baseball = read_csv('data/baseball.csv')
589590
print(baseball)
591+
baseball.info()
590592
591593
.. ipython:: python
592594
:suppress:
@@ -622,19 +624,8 @@ option:
622624
623625
reset_option('line_width')
624626
625-
You can also disable this feature via the ``expand_frame_repr`` option:
626-
627-
.. ipython:: python
628-
629-
set_option('expand_frame_repr', False)
630-
631-
DataFrame(randn(3, 12))
632-
633-
.. ipython:: python
634-
:suppress:
635-
636-
reset_option('expand_frame_repr')
637-
627+
You can also disable this feature via the ``expand_frame_repr`` option.
628+
This will print the table in one block.
638629

639630
DataFrame column attribute access and IPython completion
640631
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/source/faq.rst

+16-12
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,25 @@ horizontal scrolling, auto-detection of width/height.
3636
To appropriately address all these environments, the display behavior is controlled
3737
by several options, which you're encouraged to tweak to suit your setup.
3838

39-
As of 0.12, these are the relevant options, all under the `display` namespace,
40-
(e.g. display.width, etc'):
39+
As of 0.13, these are the relevant options, all under the `display` namespace,
40+
(e.g. ``display.width``, etc.):
4141

4242
- notebook_repr_html: if True, IPython frontends with HTML support will display
4343
dataframes as HTML tables when possible.
44-
- expand_repr (default True): when the frame width cannot fit within the screen,
45-
the output will be broken into multiple pages to accomedate. This applies to
46-
textual (as opposed to HTML) display only.
47-
- max_columns: max dataframe columns to display. a wider frame will trigger
48-
a summary view, unless `expand_repr` is True and HTML output is disabled.
49-
- max_rows: max dataframe rows display. a longer frame will trigger a summary view.
50-
- width: width of display screen in characters, used to determine the width of lines
51-
when expand_repr is active, Setting this to None will trigger auto-detection of terminal
52-
width, this only works for proper terminals, not IPython frontends such as ipnb.
53-
width is ignored in IPython notebook, since the browser provides horizontal scrolling.
44+
- large_repr (default 'truncate'): when a :class:`~pandas.DataFrame`
45+
exceeds max_columns or max_rows, it can be displayed either as a
46+
truncated table or, with this set to 'info', as a short summary view.
47+
- max_columns (default 20): max dataframe columns to display.
48+
- max_rows (default 60): max dataframe rows display.
49+
50+
Two additional options only apply to displaying DataFrames in terminals,
51+
not to the HTML view:
52+
53+
- expand_repr (default True): when the frame width cannot fit within
54+
the screen, the output will be broken into multiple pages.
55+
- width: width of display screen in characters, used to determine the
56+
width of lines when expand_repr is active. Setting this to None will
57+
trigger auto-detection of terminal width.
5458

5559
IPython users can use the IPython startup file to import pandas and set these
5660
options automatically when starting up.

doc/source/v0.13.0.txt

+16
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,22 @@ HDFStore API Changes
375375
via the option ``io.hdf.dropna_table`` (:issue:`4625`)
376376
- pass thru store creation arguments; can be used to support in-memory stores
377377

378+
DataFrame repr Changes
379+
~~~~~~~~~~~~~~~~~~~~~~
380+
381+
The HTML and plain text representations of :class:`DataFrame` now show
382+
a truncated view of the table once it exceeds a certain size, rather
383+
than switching to the short info view (:issue:`4886`, :issue:`5550`).
384+
This makes the representation more consistent as small DataFrames get
385+
larger.
386+
387+
.. image:: _static/df_repr_truncated.png
388+
:alt: Truncated HTML representation of a DataFrame
389+
390+
To get the info view, call :meth:`DataFrame.info`. If you prefer the
391+
info view as the repr for large DataFrames, you can set this by running
392+
``set_option('display.large_repr', 'info')``.
393+
378394
Enhancements
379395
~~~~~~~~~~~~
380396

pandas/core/config_init.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,19 @@
166166

167167
pc_max_info_rows_doc = """
168168
: int or None
169-
max_info_rows is the maximum number of rows for which a frame will
170-
perform a null check on its columns when repr'ing To a console.
171-
The default is 1,000,000 rows. So, if a DataFrame has more
172-
1,000,000 rows there will be no null check performed on the
173-
columns and thus the representation will take much less time to
174-
display in an interactive session. A value of None means always
175-
perform a null check when repr'ing.
169+
Deprecated.
170+
"""
171+
172+
pc_max_info_rows_deprecation_warning = """\
173+
max_info_rows has been deprecated, as reprs no longer use the info view.
174+
"""
175+
176+
pc_large_repr_doc = """
177+
: 'truncate'/'info'
178+
179+
For DataFrames exceeding max_rows/max_cols, the repr (and HTML repr) can
180+
show a truncated table (the default from 0.13), or switch to the view from
181+
df.info() (the behaviour in earlier versions of pandas).
176182
"""
177183

178184
pc_mpl_style_doc = """
@@ -220,6 +226,8 @@ def mpl_style_cb(key):
220226
cf.register_option('max_colwidth', 50, max_colwidth_doc, validator=is_int)
221227
cf.register_option('max_columns', 20, pc_max_cols_doc,
222228
validator=is_instance_factory([type(None), int]))
229+
cf.register_option('large_repr', 'truncate', pc_large_repr_doc,
230+
validator=is_one_of_factory(['truncate', 'info']))
223231
cf.register_option('max_info_columns', 100, pc_max_info_cols_doc,
224232
validator=is_int)
225233
cf.register_option('colheader_justify', 'right', colheader_justify_doc,
@@ -258,6 +266,9 @@ def mpl_style_cb(key):
258266
msg=pc_height_deprecation_warning,
259267
rkey='display.max_rows')
260268

269+
cf.deprecate_option('display.max_info_rows',
270+
msg=pc_max_info_rows_deprecation_warning)
271+
261272
tc_sim_interactive_doc = """
262273
: boolean
263274
Whether to simulate interactive mode for purposes of testing

0 commit comments

Comments
 (0)