Skip to content

Commit 6d07d2e

Browse files
FIX printing index with display.max_seq_items=None (GH10182)
1 parent 0d2b030 commit 6d07d2e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

doc/source/whatsnew/v0.17.0.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Bug Fixes
6161
~~~~~~~~~
6262

6363
- Bug in ``Categorical`` repr with ``display.width`` of ``None`` in Python 3 (:issue:`10087`)
64-
64+
- Bug in Index repr when using the ``max_seq_items=None`` setting (:issue:`10182`).
6565

6666
- Bug where Panel.from_dict does not set dtype when specified (:issue:`10058`)
6767
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
@@ -74,5 +74,3 @@ Bug Fixes
7474
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
7575

7676
- Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
77-
78-

pandas/core/index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def _format_data(self):
443443

444444
n = len(self)
445445
sep = ','
446-
max_seq_items = get_option('display.max_seq_items')
446+
max_seq_items = get_option('display.max_seq_items') or n
447447
formatter = self._formatter_func
448448

449449
# do we want to justify (only do so for non-objects)
@@ -534,7 +534,7 @@ def _format_attrs(self):
534534
attrs.append(('dtype',"'%s'" % self.dtype))
535535
if self.name is not None:
536536
attrs.append(('name',default_pprint(self.name)))
537-
max_seq_items = get_option('display.max_seq_items')
537+
max_seq_items = get_option('display.max_seq_items') or len(self)
538538
if len(self) > max_seq_items:
539539
attrs.append(('length',len(self)))
540540
return attrs
@@ -2955,7 +2955,7 @@ def _format_attrs(self):
29552955
if self.name is not None:
29562956
attrs.append(('name',default_pprint(self.name)))
29572957
attrs.append(('dtype',"'%s'" % self.dtype))
2958-
max_seq_items = get_option('display.max_seq_items')
2958+
max_seq_items = get_option('display.max_seq_items') or len(self)
29592959
if len(self) > max_seq_items:
29602960
attrs.append(('length',len(self)))
29612961
return attrs

pandas/tests/test_index.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ def test_str(self):
133133
self.assertTrue("'foo'" in str(idx))
134134
self.assertTrue(idx.__class__.__name__ in str(idx))
135135

136+
def test_repr_max_seq_item_setting(self):
137+
# GH10182
138+
idx = self.create_index()
139+
idx = idx.repeat(50)
140+
with pd.option_context("display.max_seq_items", None):
141+
repr(idx)
142+
self.assertFalse('...' in str(idx))
143+
136144
def test_wrong_number_names(self):
137145
def testit(ind):
138146
ind.names = ["apple", "banana", "carrot"]

0 commit comments

Comments
 (0)