Jupyter Notebook中显示多个输出和pd.to_csv中文乱码问题

Jupyter Notebook的一个优点是它实质上是Ipython的延申,Notebook里面输出的格式非常好,但是如果有多个输出就不行了。上面的网页介绍了一个tip,当然也有办法永久改变这一点。

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
In Windows, the steps below makes the change permanent. Should work for other operating systems. You might have to change the path.

C:\Users\your_profile\\.ipython\profile_default
C:\Users\xuzhen\Anaconda3\pkgs\ipython-7.12.0-py37h5ca1d4c_0\Lib\site-packages\IPython\core\profile  (我的情况)
Make a ipython_config.py file in the profile_defaults with the following code:

c = get_config()

c.InteractiveShell.ast_node_interactivity = "all"

pandas 之 to_csv 保存数据出现中文乱码问题及解决办法

使用 df.to_csv(file_name2, encoding=’utf-8′) 后还是编码有问题

使用 df.to_csv(file_name2, encoding=’utf_8_sig’) 后中文乱码问题解决了

df.to_csv(file_name3,encoding="utf_8_sig")
df.to_csv(file_name2,encoding="utf_8")

Please follow and like us:

Leave a Reply