Skip to content

Commit be80898

Browse files
committed
Truncate repr by default rather than changing to info view.
Truncate wide HTML repr rather than changing format. Truncate HTML repr for DataFrames with MultiIndex-es Add tests for long & wide Dataframe HTML reprs Remove now-dead code for info display in HTML repr. Fix HTML repr of wide tables with named indices Make plain text repr follow HTML repr, truncating large DataFrames Fix up tests for string repr Update docs for DataFrame reprs Add an option to switch back to info repr for large DataFrames
1 parent 044ee06 commit be80898

File tree

6 files changed

+303
-155
lines changed

6 files changed

+303
-155
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/v0.13.0.txt

+6
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ Enhancements
607607
output datetime objects should be formatted. Datetimes encountered in the
608608
index, columns, and values will all have this formatting applied. (:issue:`4313`)
609609
- ``DataFrame.plot`` will scatter plot x versus y by passing ``kind='scatter'`` (:issue:`2215`)
610+
- The HTML and plain text representations of :class:`DataFrame` now show
611+
a truncated view of the table once it exceeds a certain size, rather
612+
than switching to the short info view (:issue:`4886`, :issue:`5550`).
613+
This makes the representation more consistent as small DataFrames get
614+
larger. To get the info view, call :meth:`DataFrame.info`, or restore
615+
the old behaviour with ``set_option('display.large_repr', 'info')``.
610616

611617
.. _whatsnew_0130.experimental:
612618

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)