Skip to content

BUG: categorical doesn't handle display.width of None in Python 3  #10087

Closed
@rosnfeld

Description

@rosnfeld

Categorical Series have a special repr that looks at display.width, which can be None if following the Options and Settings docs. Unlike Python 2, in Python 3 an integer vs None comparison throws an exception.

(on current master, and has been true for several releases now)

Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.core.config.set_option('display.width', None)
>>> import numpy as np
>>> x = pd.Series(np.random.randn(100))
>>> pd.cut(x, 10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/base.py", line 67, in __repr__
    return str(self)
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/base.py", line 46, in __str__
    return self.__unicode__()
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/series.py", line 897, in __unicode__
    max_rows=max_rows)
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/series.py", line 962, in to_string
    name=name, max_rows=max_rows)
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/series.py", line 992, in _get_repr
    result = formatter.to_string()
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/format.py", line 222, in to_string
    footer = self._get_footer()
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/format.py", line 196, in _get_footer
    level_info = self.tr_series.values._repr_categories_info()
  File "/home/andrew/git/pandas-rosnfeld-py3/pandas/core/categorical.py", line 1323, in _repr_categories_info
    if max_width != 0 and cur_col_len + sep_len + len(val) > max_width:
TypeError: unorderable types: int() > NoneType()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions