如何在Jupyter Notebook直接输出(render)图片

http://pyecharts.org/#/zh-cn/render_images

官网虽然有介绍,但是思路不清晰,没有分类的step-by-step,我一通乱撞终于弄好了。最后参考:

  • 我们的目的是实现:
  • make_snapshot(snapshot, '2019-nCoV 数据一览.html', "2019-nCoV 数据一览.png")
  • $ pip install pyecharts-snapshot
  • $ pip install snapshot-selenium

Usage details

Command line options:

$ snapshot output.html [png|jpeg|gif|svg|pdf] [delay] [pixel ratio]
make_snapshot(snapshot, chart_function().render(), "outputfile.png")

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")