Skip to content

Commit 4360afa

Browse files
FIX printing index with display.max_seq_items=None (GH10182)
1 parent eea9361 commit 4360afa

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

doc/source/whatsnew/v0.16.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Bug Fixes
137137
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
138138
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
139139

140+
- Bug in Index repr when using the ``max_seq_items=None`` setting (:issue:`10182`).
140141

141142
- Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`)
142143
- Bug in display datetimes with mixed frequencies uniformly; display 'ms' datetimes to the proper precision. (:issue:`10170`)

pandas/core/index.py

+3-3
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
@@ -2950,7 +2950,7 @@ def _format_attrs(self):
29502950
if self.name is not None:
29512951
attrs.append(('name',default_pprint(self.name)))
29522952
attrs.append(('dtype',"'%s'" % self.dtype))
2953-
max_seq_items = get_option('display.max_seq_items')
2953+
max_seq_items = get_option('display.max_seq_items') or len(self)
29542954
if len(self) > max_seq_items:
29552955
attrs.append(('length',len(self)))
29562956
return attrs

pandas/tests/test_index.py

+8
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)