BUG: _tidy_repr should not be called when max_rows is None by unutbu · Pull Request #6863 · pandas-dev/pandas (original) (raw)

This issue was raised in http://stackoverflow.com/q/22824104/190597:

import pandas as pd
pd.options.display.max_rows = None
result = pd.Series(range(1001))
print(result)

raises TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'.

The problem occurs in series.py (line 832) when max_rows is None:

    if len(self.index) > (max_rows or 1000):
        result = self._tidy_repr(min(30, max_rows - 4))

Since the doc string for get_options says

display.max_rows: [default: 60] [currently: 60]
        ...
        'None' value means unlimited.

I think _tidy_repr should not be called when max_rows is None.

This PR seems simple enough but my main concern is that this PR stomps on GH1467 which explicitly changed > max_rows to > (max_rows or 1000) and I don't know what the purpose of this was.