Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rosnfeld opened this issue May 8, 2015 · 2 comments · Fixed by #10108
Closed

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

rosnfeld opened this issue May 8, 2015 · 2 comments · Fixed by #10108
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@rosnfeld
Copy link
Contributor

rosnfeld commented May 8, 2015

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()
@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string 2/3 Compat labels May 9, 2015
@jreback jreback added this to the Next Major Release milestone May 9, 2015
@jreback
Copy link
Contributor

jreback commented May 9, 2015

should be a simple fix. PR's are welcome.

@rosnfeld
Copy link
Contributor Author

rosnfeld commented May 9, 2015

Sure, I'll try and get to it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants