Python 3.5 Jupyter 笔记本 ggplot "name error"

标签 python python-3.5 python-ggplot

在运行 Python 3.5.2 的 Jupyter Notebook 中使用 yHat 的 Python ggplot 库(请参阅下面的完整错误)时,出现 NameError: name 'unicode' is not Defined。具有以下导入语句:

 %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

最佳答案

如果您安装了 anaconda,请尝试安装 code-forge 版本。我能够通过切换到 python 3.5 的版本来解决同样的问题

conda install -c conda-forge ggplot

希望有帮助

关于Python 3.5 Jupyter 笔记本 ggplot "name error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38247973/

相关文章:

python - Pymysql无法导入python3

json - EDI X12 到 JSON 解析器 Python 3.5 可用吗?

python - 有没有办法在 ggplot 中绘制 Pandas 系列?

python - Matplotlib 等同于 ggplot geom_ribbon?

python - 无法在 Windows 10 上使用 pip 安装 Vowpalwabbit

python - 从字符串列表中删除某些字符串作为 pandas.DataFrame 中的列

Python GUI - 2.7 至 3.5

python ggplot图例大小

python - Swift 等效于 Python 切片赋值

python - 在 NumPy 中根据相邻值计算值的惯用方法是什么?