From e465b81ff372e2665745232f56fe4595bbd89647 Mon Sep 17 00:00:00 2001 From: unutbu Date: Thu, 10 Apr 2014 13:23:38 -0400 Subject: [PATCH] BUG: _tidy_repr should not be called when max_rows is None http://stackoverflow.com/q/22824104/190597 --- doc/source/release.rst | 1 + pandas/core/series.py | 2 +- pandas/tests/test_series.py | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 2ac6d96c5a36b..e37a7c7eab861 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -364,6 +364,7 @@ Bug Fixes - Bug in ``DataFrame.replace()`` where changing a dtype through replacement would only replace the first occurrence of a value (:issue:`6689`) - Better error message when passing a frequency of 'MS' in ``Period`` construction (GH5332) +- Bug in `Series.__unicode__` when `max_rows` is `None` and the Series has more than 1000 rows. (:issue:`6863`) pandas 0.13.1 ------------- diff --git a/pandas/core/series.py b/pandas/core/series.py index 3b1c7a6af5069..70b73c56772aa 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -828,7 +828,7 @@ def __unicode__(self): width, height = get_terminal_size() max_rows = (height if get_option("display.max_rows") == 0 else get_option("display.max_rows")) - if len(self.index) > (max_rows or 1000): + if max_rows and len(self.index) > max_rows: result = self._tidy_repr(min(30, max_rows - 4)) elif len(self.index) > 0: result = self._get_repr(print_header=True, diff --git a/pandas/tests/test_series.py b/pandas/tests/test_series.py index 73dd47ee3d3e4..5b088598dfcec 100644 --- a/pandas/tests/test_series.py +++ b/pandas/tests/test_series.py @@ -1770,6 +1770,11 @@ def test_repr_should_return_str(self): df = Series(data, index=index1) self.assertTrue(type(df.__repr__() == str)) # both py2 / 3 + def test_repr_max_rows(self): + # GH 6863 + with pd.option_context('max_rows', None): + str(Series(range(1001))) # should not raise exception + def test_unicode_string_with_unicode(self): df = Series([u("\u05d0")], name=u("\u05d1")) if compat.PY3: