Skip to content

Commit ea883e0

Browse files
committed
Merge pull request #6863 from unutbu/max-rows
BUG: _tidy_repr should not be called when max_rows is None
2 parents bc4bbf1 + e465b81 commit ea883e0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ Bug Fixes
364364
- Bug in ``DataFrame.replace()`` where changing a dtype through replacement
365365
would only replace the first occurrence of a value (:issue:`6689`)
366366
- Better error message when passing a frequency of 'MS' in ``Period`` construction (GH5332)
367+
- Bug in `Series.__unicode__` when `max_rows` is `None` and the Series has more than 1000 rows. (:issue:`6863`)
367368

368369
pandas 0.13.1
369370
-------------

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def __unicode__(self):
828828
width, height = get_terminal_size()
829829
max_rows = (height if get_option("display.max_rows") == 0
830830
else get_option("display.max_rows"))
831-
if len(self.index) > (max_rows or 1000):
831+
if max_rows and len(self.index) > max_rows:
832832
result = self._tidy_repr(min(30, max_rows - 4))
833833
elif len(self.index) > 0:
834834
result = self._get_repr(print_header=True,

pandas/tests/test_series.py

+5
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,11 @@ def test_repr_should_return_str(self):
17701770
df = Series(data, index=index1)
17711771
self.assertTrue(type(df.__repr__() == str)) # both py2 / 3
17721772

1773+
def test_repr_max_rows(self):
1774+
# GH 6863
1775+
with pd.option_context('max_rows', None):
1776+
str(Series(range(1001))) # should not raise exception
1777+
17731778
def test_unicode_string_with_unicode(self):
17741779
df = Series([u("\u05d0")], name=u("\u05d1"))
17751780
if compat.PY3:

0 commit comments

Comments
 (0)