jupyter note 快捷键 : 内联matplotlib 和 多变量显示

  • 启动本地notebook,打开Windows命令行,键入:ipython notebook
  • 配置notebook,打开Windows命令行,键入:ipython profile create,会生成.ipython\profile_default\ipython_config.py等配置文件
  • 1、例如,想要内联matplotlib的图片,可以在ipython_kernel_config.py中加入
# Configuration file for ipython-kernel.
c = get_config()
c.IPKernelApp.matplotlib = 'inline'


2、多变量显示

有一点已经众所周知。把变量名称或没有定义输出结果的语句放在 cell 的最后一行,无需 print 语句,Jupyter 也会显示变量值。当使用 Pandas DataFrames 时这一点尤其有用,因为输出结果为整齐的表格。 

鲜为人知的是,你可以通过修改内核选项 ast_note_interactivity,使得 Jupyter 对独占一行的所有变量或者语句都自动显示,这样你就可以马上看到多个语句的运行结果了。

In [ 1 ] : from IPython.core.interactiveshell import InteractiveShell

        InteractiveShell.ast_node_interactivity = "all"


如果你想在各种情形下(Notebook 和 Console)Jupyter 都同样处理,打开 ipython_config.py 文件并修改:

## An enhanced, interactive shell for Python.

# 'all', 'last', 'last_expr' or 'none', 'last_expr_or_assign' specifying which
#  nodes should be run interactively (displaying output from expressions).
c.InteractiveShell.ast_node_interactivity = 'all'


3、

notebook 自带一组快捷键,能提高效率(感 jio 有点要脱离鼠标了)。下面大概总结一下,也方便以后使用。notebook里每一个叫做cell。

两种模式

Command mode 和 Edit mode。 在一个cell中,按下Enter,进入Edit模式,按下Esc,进入Command 模式

运行当前cell,并移动到下一个Cell

在一个cell中(在command模式下),  Shift + Enter  

创建Cell

在一个cell中(在command模式下)
1. 按下 a ,即可在这个cell之前创建一个新的cell;
2. 按下 b,即可在这个cell之后创建一个新的cell;

Cell中 Code 和 Markdown的切换

在一个cell中(在command模式下)
1. 按下 y, 进入Code;
2. 按下m, 进入Markdown;

显示Cell中的行数

在一个cell中(在command模式下),按下 l

删除Cell

在一个cell中(在command模式下), 按两次 d

保存Notebook

在一个cell中(在command模式下), 按下 s

启动命令面板

在一个cell中(在command模式下), 按下 Ctrl + Shift + P 
界面中的小键盘也可以启动:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值