我在NameError: name 'unicode' is not defined
运行 Python 3.5.2 的 Jupyter Notebook 中使用 yHat 的 Python ggplot 库(请参阅下面的完整错误)时得到。使用以下导入语句:
%matplotlib inline
from ggplot import *
该图仍然呈现,但我想消除错误,或者如果它没有引起重大冲突,则将其隐藏。
完整的错误如下。提前谢谢了 :)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
//anaconda/lib/python3.5/site-packages/IPython/core/formatters.py in __call__(self, obj)
697 type_pprinters=self.type_printers,
698 deferred_pprinters=self.deferred_printers)
--> 699 printer.pretty(obj)
700 printer.flush()
701 return stream.getvalue()
//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in pretty(self, obj)
381 if callable(meth):
382 return meth(obj, self, cycle)
--> 383 return _default_pprint(obj, self, cycle)
384 finally:
385 self.end_group()
//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in _default_pprint(obj, p, cycle)
501 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
502 # A user-provided repr. Find newlines and replace them with p.break_()
--> 503 _repr_pprint(obj, p, cycle)
504 return
505 p.begin_group(1, '<')
//anaconda/lib/python3.5/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
692 """A pprint that just redirects to the normal repr function."""
693 # Find newlines and replace them with p.break_()
--> 694 output = repr(obj)
695 for idx,output_line in enumerate(output.splitlines()):
696 if idx:
//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in __repr__(self)
113 Evaluates patsy expressions within the aesthetics. For example, 'x + 1'
114 , 'factor(x)', or 'pd.cut(price, bins=10)')
--> 115 """
116 for key, item in self._aes.items():
117 if item not in self.data:
//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in make(self)
//anaconda/lib/python3.5/site-packages/ggplot/ggplot.py in apply_axis_labels(self)
269 i, j = self.subplots.shape
270 i, j = int((i - 1) / 2), int(j - 1)
--> 271 ax = self.subplots[i][j]
272 make_legend(ax, legend)
273 elif self.facets.rowvar:
NameError: name 'unicode' is not defined