|
13 | 13 | from numpy.random import randn
|
14 | 14 | import numpy as np
|
15 | 15 |
|
16 |
| -from pandas import DataFrame, Series, Index, _np_version_under1p7, Timestamp |
| 16 | +from pandas import DataFrame, Series, Index, _np_version_under1p7, Timestamp, MultiIndex |
17 | 17 |
|
18 | 18 | import pandas.core.format as fmt
|
19 | 19 | import pandas.util.testing as tm
|
@@ -2057,6 +2057,42 @@ def test_mixed_datetime64(self):
|
2057 | 2057 | result = repr(df.ix[0])
|
2058 | 2058 | self.assertTrue('2012-01-01' in result)
|
2059 | 2059 |
|
| 2060 | + def test_max_multi_index_display(self): |
| 2061 | + # GH 7101 |
| 2062 | + |
| 2063 | + # doc example (indexing.rst) |
| 2064 | + |
| 2065 | + # multi-index |
| 2066 | + arrays = [['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'], |
| 2067 | + ['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']] |
| 2068 | + tuples = list(zip(*arrays)) |
| 2069 | + index = MultiIndex.from_tuples(tuples, names=['first', 'second']) |
| 2070 | + s = Series(randn(8), index=index) |
| 2071 | + |
| 2072 | + with option_context("display.max_rows", 10): |
| 2073 | + self.assertEquals(len(str(s).split('\n')),10) |
| 2074 | + with option_context("display.max_rows", 3): |
| 2075 | + self.assertEquals(len(str(s).split('\n')),5) |
| 2076 | + with option_context("display.max_rows", 2): |
| 2077 | + self.assertEquals(len(str(s).split('\n')),5) |
| 2078 | + with option_context("display.max_rows", 1): |
| 2079 | + self.assertEquals(len(str(s).split('\n')),5) |
| 2080 | + with option_context("display.max_rows", 0): |
| 2081 | + self.assertEquals(len(str(s).split('\n')),10) |
| 2082 | + |
| 2083 | + # index |
| 2084 | + s = Series(randn(8), None) |
| 2085 | + |
| 2086 | + with option_context("display.max_rows", 10): |
| 2087 | + self.assertEquals(len(str(s).split('\n')),9) |
| 2088 | + with option_context("display.max_rows", 3): |
| 2089 | + self.assertEquals(len(str(s).split('\n')),4) |
| 2090 | + with option_context("display.max_rows", 2): |
| 2091 | + self.assertEquals(len(str(s).split('\n')),4) |
| 2092 | + with option_context("display.max_rows", 1): |
| 2093 | + self.assertEquals(len(str(s).split('\n')),4) |
| 2094 | + with option_context("display.max_rows", 0): |
| 2095 | + self.assertEquals(len(str(s).split('\n')),9) |
2060 | 2096 |
|
2061 | 2097 | class TestEngFormatter(tm.TestCase):
|
2062 | 2098 | _multiprocess_can_split_ = True
|
|
0 commit comments