From bbe43062e012deeb612499a266fd10793a26da25 Mon Sep 17 00:00:00 2001 From: y-p Date: Fri, 26 Apr 2013 21:41:46 +0300 Subject: [PATCH 1/3] BUG/ENH: (Multi)Index pprint items by type correctly, obeys display.max_seq_items GH3465 --- pandas/core/index.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/pandas/core/index.py b/pandas/core/index.py index 5ffd211c86d27..34edd26a49617 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -170,12 +170,7 @@ def __unicode__(self): Invoked by unicode(df) in py2 only. Yields a Unicode String in both py2/py3. """ - if len(self) > 6 and len(self) > np.get_printoptions()['threshold']: - data = self[:3].format() + ["..."] + self[-3:].format() - else: - data = self.format() - - prepr = com.pprint_thing(data, escape_chars=('\t', '\r', '\n'),quote_strings=True) + prepr = com.pprint_thing(self, escape_chars=('\t', '\r', '\n'),quote_strings=True) return '%s(%s, dtype=%s)' % (type(self).__name__, prepr, self.dtype) def __repr__(self): @@ -1504,19 +1499,9 @@ def __unicode__(self): """ output = 'MultiIndex\n%s' - options = np.get_printoptions() - np.set_printoptions(threshold=50) - - if len(self) > 100: - values = self[:50].format() + ["..."] + self[-50:].format() - else: - values = self.format() - - summary = com.pprint_thing(values, escape_chars=('\t', '\r', '\n'), + summary = com.pprint_thing(self, escape_chars=('\t', '\r', '\n'), quote_strings=True) - np.set_printoptions(threshold=options['threshold']) - return output % summary def __repr__(self): From 887047538c0abbf93500413ca1de38ffb936f3dd Mon Sep 17 00:00:00 2001 From: y-p Date: Fri, 26 Apr 2013 21:44:21 +0300 Subject: [PATCH 2/3] TST: adjust test_repr_summary to set display.max_seq_items --- pandas/tests/test_index.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/tests/test_index.py b/pandas/tests/test_index.py index 65a3d3b1c8a20..993fc690ad04e 100644 --- a/pandas/tests/test_index.py +++ b/pandas/tests/test_index.py @@ -17,6 +17,7 @@ import pandas.core.common as com import pandas.util.testing as tm +import pandas.core.config as cf from pandas.tseries.index import _to_m8 import pandas.tseries.offsets as offsets @@ -895,9 +896,10 @@ def test_print_unicode_columns(self): repr(df.columns) # should not raise UnicodeDecodeError def test_repr_summary(self): - r = repr(pd.Index(np.arange(10000))) - self.assertTrue(len(r) < 100) - self.assertTrue("..." in r) + with cf.option_context('display.max_seq_items',10): + r = repr(pd.Index(np.arange(1000))) + self.assertTrue(len(r) < 100) + self.assertTrue("..." in r) def test_unicode_string_with_unicode(self): idx = Index(range(1000)) From 69059a3c2d3e0894eb4196046c4d0da1f4797e8f Mon Sep 17 00:00:00 2001 From: y-p Date: Fri, 26 Apr 2013 21:52:05 +0300 Subject: [PATCH 3/3] DOC: update RELEASE.rst PTF --- RELEASE.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE.rst b/RELEASE.rst index aac34c6cf8a5e..9920f89d50501 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -42,6 +42,8 @@ pandas 0.12.0 - When removing an object from a store, **store.remove(key)**, raises **KeyError** if **key** is not a valid store object. + - The repr() for (Multi)Index now obeys display.max_seq_items rather + then numpy threshold print options. (GH3426_, GH3466_) **Bug Fixes** @@ -60,6 +62,8 @@ pandas 0.12.0 .. _GH3379: https://github.com/pydata/pandas/issues/3379 .. _GH3454: https://github.com/pydata/pandas/issues/3454 .. _GH3457: https://github.com/pydata/pandas/issues/3457 +.. _GH3426: https://github.com/pydata/pandas/issues/3426 +.. _GH3466: https://github.com/pydata/pandas/issues/3466 .. _GH3038: https://github.com/pydata/pandas/issues/3038 .. _GH3437: https://github.com/pydata/pandas/issues/3437 .. _GH3455: https://github.com/pydata/pandas/issues/3455