我想让我的python代码的打印结果正确对齐。
虽然我已经得到了@jezrael在堆栈溢出中的建议,并添加了以下代码:
pd.set_option('display.unicode.east_asian_width', True).
请参阅我在本网站发布的问题:Python Pandas: print the csv data in oder with columns
虽然它适用于vagrant(python 3版本)和emac环境,但我无法在终端环境(python 2版本)中工作并且打印错误:
pandas.core.config.OptionError: "No such keys(s): 'display.unicode.eat_asian_width'
taka-no-MacBook-Pro:Desktop tianke0711$ python test_plot.py
Traceback (most recent call last):
File "test_plot.py", line 8, in <module>
pd.set_option('display.unicode.east_asian_width', True)
File "//anaconda/lib/python2.7/site-packages/pandas/core/config.py", line 222, in __call__
return self.__func__(*args, **kwds)
File "//anaconda/lib/python2.7/site-packages/pandas/core/config.py", line 119, in _set_option
key = _get_single_key(k, silent)
File "//anaconda/lib/python2.7/site-packages/pandas/core/config.py", line 83, in _get_single_key
raise OptionError('No such keys(s): %r' % pat)
pandas.core.config.OptionError: "No such keys(s):
'display.unicode.eat_asian_width'
我不知道如何解决,请帮助我,谢谢!
答案 0 :(得分:1)
由于python版本不同。更多,不同版本的python有不同版本的pandas。我目前使用的python 2.7有pandas:0.16.2,这个版本的pandas没有没有这样的键:&#39; display.unicode.at_asian_width&#39;,并导致错误。但是,pandas的版本:pandas-0.18.1支持这一点。
两个解决方案,1。使用python3版本2.更新pandas:conda install pandas = 0.18.1在python 2.但是当你想安装最新版本的pandas时,有错误:发现以下规范发生冲突:mayavi
首先,conda卸载mayavi,然后conda安装pandas = 0.18.1,它的工作原理。谢谢!