Jupyter Notebook is a browser bases REPL (read eval print loop) built on IPython and other open-source libraries, it allows us to run interactive python code on the browser.

Jupyter Notebook是基于IPL和其他开源库构建的基于REPL(读取评估打印循环)的浏览器,它使我们能够在浏览器上运行交互式python代码。

It not only runs python code but also has many interesting plugins and magic commands which enhances the python coding experience greatly.

它不仅运行python代码,还具有许多有趣的插件和魔术命令,从而极大地增强了python的编码体验。

1.计算单元执行时间: (1. Calculate the time of execution of a cell:)

One can calculate the time of execution of a jupyter notebook cell using magic command at the beginning of the cell. It calculates the wall time that can be referred to as the total time required to execute that cell.

可以在单元格的开头使用魔术命令来计算jupyter笔记本计算机单元的执行时间。 它计算墙壁时间 ,可以将其称为执行该单元所需的总时间。

2.进度栏: (2. Progress Bar:)

One can use a python external library to create a progress bar, that can give live updates of the progress of code. It keeps the user informed about the status of a running code script. You can get the Github repository of library here.

可以使用python外部库创建进度条,该进度条可以实时更新代码进度。 它使用户随时了解正在运行的代码脚本的状态。 您可以在此处获取Github库信息库。

First, you need to install tqdm library,

首先,您需要安装 tqdm库,

pip3 install tqdm

Or you can also install it in a jupyter notebook cell using ! .

或者,您也可以使用!将其安装在jupyter笔记本电脑中!

The tqdm function can be used by importing its package and the usage and implementation can be observed below:

可以通过导入其软件包来使用tqdm函数,其用法和实现如下所示:

3.自动代码格式化程序: (3. Automatic Code Formatter:)

Using nb_black library, one can format a code snippet in a cell to a proper format. Sometimes the code snippet in a jupyter notebook cell is not well-formatted, this library helps to attain proper formatting of the code snippet.

使用nb_black库,可以将单元格中的代码片段格式化为适当的格式。 有时,在jupyter笔记本电脑单元中的代码段格式不正确,该库有助于实现代码段的正确格式。

nb_black is a simple extension for Jupyter Notebook and Jupyter Lab to beautify Python code automatically.

nb_black是Jupyter Notebook和Jupyter Lab的简单扩展,可以自动美化Python代码。

Installation of the library:

库的安装:

pip3 install nb_black

Usage for Jupyter Notebook:

Jupyter Notebook的用法:

%load_ext nb_black
(Image by Author), Unformatted cell
(作者提供的图片),未格式化的单元格
(Image by Author), Formatted cell using nb_black
(作者提供的图像),使用nb_black格式化的单元格

4.安装软件包: (4. Install Packages:)

Jupyter Notebook can install any python package in the notebook itself. To install any python package using the pip command in jupyter notebook cell enter a ! before the command.

Jupyter Notebook可以在笔记本本身中安装任何python软件包。 要在jupyter笔记本单元中使用pip命令安装任何python软件包,请输入! 在命令之前。

For installing the pandas package: Enter ! pip install pandas and run the cell.

要安装pandas软件包:输入! pip install pandas ! pip install pandas并运行单元。

5.说明文件: (5. Documentation:)

Jupyter Notebook can show that documentation of the function you are calling. Press Shift+Tab to view the documentation. This is very helpful as you don’t need to open the documentation website every single time. This feature also works for the local custom functions.

Jupyter Notebook可以显示您正在调用的函数的文档。 按Shift+Tab查看文档。 这非常有用,因为您不需要每次都打开文档网站。 此功能也适用于本地自定义功能。

Usage:

用法:

  • Write the name of the function you want to implement写下您要实现的函数的名称
  • Press Shift+Tab to view the documentation.

    Shift+Tab查看文档。

  • Click on ^ on the top right corner of documentation to view it in a pager.

    单击文档右上角的^以在寻呼机中查看它。

  • Click on + to grow the docstring vertically.

    单击+垂直增加文档字符串。

  • Click on x to close the docstring.

    单击x关闭文档字符串。

(Image by Author), Docstring for the pandas read_csv function
(作者提供的图片),熊猫的string,read_csv函数

6.自动完成: (6. Autocomplete:)

Jupyter Notebook can show suggestions for any function name or variable. To view suggestions writing typing the code press Tab in your keyboard and the suggestion will appear in a top-down menu. Press arrow-up or arrow-down key to scroll up or down the menu. You can also scroll using your mouse. Click on the keyword or hit enter on the selected keyword to confirm your suggestion.

Jupyter Notebook可以显示有关任何函数名称或变量的建议。 要查看键入代码的建议,请按键盘上的Tab键,该建议将显示在自上而下的菜单中。 按arrow-uparrow-down键向上或向下滚动菜单。 您也可以使用鼠标滚动。 单击关键字或在选定的关键字上按Enter键以确认您的建议。

You will also get suggestions for custom functions and variables.

您还将获得有关自定义函数和变量的建议。

(Image by Author), Suggestions from the pandas package
(作者提供的图片),来自熊猫包装的建议

7.调整输出视图: (7. Adjust the view of Output:)

Jupyter Notebook can print the output of each cell just below the cell. When you have a lot of output you can reduce the amount of space it takes up by clicking on the left side panel of the output. This will turn the output into a scrolling window. Double click on the left side of the output to completely collapse the output panel.

Jupyter Notebook可以在单元格正下方打印每个单元格的输出。 当您有很多输出时,可以通过单击输出的左侧面板来减少占用的空间。 这会将输出转换为滚动窗口。 双击输出的左侧以完全折叠输出面板。

You can repeat the process of a single click or double click to change the format of viewing the output panel.

您可以重复单击或双击的过程来更改查看输出面板的格式。

(Gif by Author), Click on the left side of the panel to change the view of the output screen
(按作者显示),点击面板左侧以更改输出屏幕的视图

8.单元执行功能: (8. Cell Execution Features:)

Jupyter Notebook has certain cell execution features that ease the programmer’s performance.

Jupyter Notebook具有某些单元执行功能,可减轻程序员的性能。

  • Shit+Enter will run the current cell and highlight the next cell, if no cell is present it will create a new cell.Shit + Enter将运行当前单元格并突出显示下一个单元格,如果不存在任何单元格,则会创建一个新单元格。
  • Alt+Enter will run the current cell and insert a new cell and highlight it.Alt + Enter将运行当前单元格并插入一个新单元格并突出显示它。

9.降价: (9. Markdown:)

Jupyter notebook cells can not only run code snippets but also be used to write text. Markdown cells can be used to write text descriptions. It is a better way to express than using comments.

Jupyter笔记本单元不仅可以运行代码段,还可以用于编写文本。 Markdown单元格可用于编写文本描述。 与使用注释相比,这是一种更好的表达方式。

Usage:

用法:

  • Click on the cell to convert it to markdown.单击单元格以将其转换为降价。
  • Choose the Markdown option from the drop-down menu从下拉菜单中选择Markdown选项
(Image by Author), Covert code cell to markdown cells
(作者提供的图片),隐式代码单元到降价单元
Source)来源 )

10.在笔记本中运行来自不同语言的代码: (10. Run code from different languages in the notebook:)

Jupyter Notebook cells can also be used to compile and run code from different languages using IPython magic commands. Use IPython Magics with the name of your kernel at the start of each cell that you want to use that cell for:

Jupyter Notebook单元还可以用于使用IPython magic命令编译和运行来自不同语言的代码。 在每个要用于该单元格的单元格的开头,将IPython Magics与内核名称一起使用:

  • %%bash

    %%bash

  • %%HTML

    %%HTML

  • %%python2

    %%python2

  • %%python3

    %%python3

  • %%ruby

    %%ruby

  • %%perl

    %%perl

(Image by Author), HTML code snippet in jupyter notebook cell
(作者提供的图片),jupyter笔记本单元格中HTML代码段

11.多光标: (11. Multiple Cursor:)

Jupyter Notebook supports editing code using multiple cursors at once. To select the code to edit at once press Alt key and select the code snippet using your mouse. After selection, you can now edit the code using multiple cursors at once.

Jupyter Notebook支持一次使用多个光标编辑代码。 要立即选择要编辑的代码,请按Alt键,然后使用鼠标选择代码段。 选择后,您现在可以一次使用多个光标编辑代码。

12.从Jupyter Notebook创建演示文稿: (12. Creating Presentation from Jupyter Notebook:)

Jupyter Notebook can be used to create a PowerPoint-style presentation. Here each cell or group of cells of the notebook can be treated as each slide.

Jupyter Notebook可用于创建PowerPoint样式的演示文稿。 在这里,笔记本的每个单元格或单元格组都可以视为每个幻灯片。

  • Firstly, install RISE using conda: conda install -c damianavila82 rise

    首先,使用conda install -c damianavila82 rise安装RISE : conda install -c damianavila82 rise

  • Enter/Exit RISE Slideshow button appears in the notebook toolbar. A slideshow option will also appear under View>Cell Toolbar>Slideshow输入/退出RISE幻灯片显示按钮出现在笔记本工具栏中。 幻灯片选项也会出现在“视图”>“单元格工具栏”>“幻灯片”下
  • To prepare Slideshow click on View>Cell Toolbar>Slideshow and select the jupyter notebook cells for each slide.要准备幻灯片,请单击“视图”>“单元格工具栏”>“幻灯片”,然后为每张幻灯片选择jupyter笔记本单元。
  • After selecting each slide click on the RISE Slideshow button in the notebook toolbar.选择每张幻灯片后,单击笔记本工具栏中的“ RISE幻灯片”按钮。

Visit here for detailed video guide usage.

请访问此处以获取详细的视频指南用法。

Source)来源 )

13.共享Jupyter笔记本: (13. Share Jupyter Notebooks:)

After code completion, you have several options to share your jupyter notebook.

代码完成后,您可以选择几种方式来共享jupyter笔记本。

  • Download your jupyter notebook as HTML, pdf, ipynb, py file, etc.将您的jupyter笔记本下载为HTML,pdf,ipynb,py文件等。
  • You can use JupyterHub that can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server.

    您可以使用JupyterHub创建一个多用户集线器,该中心可以生成,管理和代理单用户Jupyter笔记本服务器的多个实例。

  • You can publish to medium directly from the jupyter notebook. Read this to know the steps.

    您可以直接从jupyter笔记本发布到中型媒体。 阅读本文以了解步骤。

14.在笔记本中绘图: (14. Plotting in Notebook:)

Jupyter Notebook is the best tool used for data analysis and visualization. It can be used to generate different types of plots using different python or R libraries. Some of the python libraries used to generate plots are:

Jupyter Notebook是用于数据分析和可视化的最佳工具。 它可以用于使用不同的python或R库生成不同类型的图。 用于生成图的一些python库是:

  • Matplotlib

    Matplotlib

  • Seaborn

    Seaborn

  • bokeh

    散景

  • plot.ly

    情节

Source), Different types of plots来源 ),不同类型的地块

15.键盘快捷键: (15. Keyboard Shortcuts:)

Shortcuts are used to save a lot of programmer’s time and ease the coding experience. Jupyter notebook has plenty of inbuilt keyboard shortcuts that you find under the Help menu bar: Help>Keyboard Shortcuts .

快捷方式用于节省大量程序员的时间并简化编码体验。 Jupyter Notebook具有许多内置的键盘快捷键,您可以在“ Help菜单栏下找到:“ Help>Keyboard Shortcuts

Jupyter Notebook also provides functionality to edit the keyboard shortcuts as per the programmer’s convenience. You can edit keyboard shortcuts: Help>Edit Keyboard Shortcuts .

Jupyter Notebook还提供了根据程序员的方便来编辑键盘快捷键的功能。 您可以编辑键盘快捷键: Help>Edit Keyboard Shortcuts

(Image by Author), Command Mode Keyboard Shortcuts
(作者提供的图像),命令模式键盘快捷键
(Image by Author), Edit Mode Keyboard Shortcuts
(作者提供的图像),编辑模式键盘快捷键

结论: (Conclusion:)

Jupyter Notebook is one of the best tools extensible used by folks working in the data science domain due to interactive UI. The above-discussed 15 tips and tricks will help you to ease your jupyter notebook coding experience. It has a lot more built-in magic commands that are not discussed in this article, you can have a read here. Let me know your favorite tips and comment if know more tricks.

由于交互式UI,Jupyter Notebook是数据科学领域的人们使用的最佳可扩展工具之一。 上面讨论的15个技巧和窍门将帮助您减轻Jupyter笔记本的编码体验。 它具有许多内置的魔术命令,本文不会讨论,您可以在此处阅读。 让我知道您最喜欢的技巧,如果有更多技巧,请发表评论。

  • The images used in the article are either cited or generated by the author

    本文中使用的图像由作者引用或生成

Thank You for Reading

谢谢您的阅读

翻译自: https://towardsdatascience.com/15-tips-and-tricks-for-jupyter-notebook-that-will-ease-your-coding-experience-e469207ac95c


http://www.taodudu.cc/news/show-995295.html

相关文章:

  • bi数据分析师_BI工程师和数据分析师的5个格式塔原则
  • 因果推论第六章
  • 熊猫数据集_处理熊猫数据框中的列表值
  • 数据预处理 泰坦尼克号_了解泰坦尼克号数据集的数据预处理
  • vc6.0 绘制散点图_vc有关散点图的一切
  • 事件映射 消息映射_映射幻影收费站
  • 匿名内部类和匿名类_匿名schanonymous
  • ab实验置信度_为什么您的Ab测试需要置信区间
  • 支撑阻力指标_使用k表示聚类以创建支撑和阻力
  • 均线交易策略的回测 r_使用r创建交易策略并进行回测
  • 初创公司怎么做销售数据分析_初创公司与Faang公司的数据科学
  • 机器学习股票_使用概率机器学习来改善您的股票交易
  • r psm倾向性匹配_南瓜香料指标psm如何规划季节性广告
  • 使用机器学习预测天气_如何使用机器学习预测着陆
  • 数据多重共线性_多重共线性对您的数据科学项目的影响比您所知道的要多
  • 充分利用昂贵的分析
  • 如何识别媒体偏见_描述性语言理解,以识别文本中的潜在偏见
  • 数据不平衡处理_如何处理多类不平衡数据说不可以
  • 糖药病数据集分类_使用optuna和mlflow进行心脏病分类器调整
  • mongdb 群集_群集文档的文本摘要
  • gdal进行遥感影像读写_如何使用遥感影像进行矿物勘探
  • 推荐算法的先验算法的连接_数据挖掘专注于先验算法
  • 时间序列模式识别_空气质量传感器数据的时间序列模式识别
  • 数据科学学习心得_学习数据科学
  • 数据科学生命周期_数据科学项目生命周期第1部分
  • 条件概率分布_条件概率
  • 成为一名真正的数据科学家有多困难
  • 数据驱动开发_开发数据驱动的股票市场投资方法
  • 算法偏见是什么_算法可能会使任何人(包括您)有偏见
  • 线性回归非线性回归_了解线性回归

Jupyter Notebook的15个技巧和窍门,可简化您的编码体验相关推荐

  1. Jupyter Notebook数据科学高效技巧

    摘要: 本文有一些关于Jupyter Notebook的干货,希望看完文章可以给你带来收获 当我学习有关深度学习的优秀的fast.ai课程时,我学到了很多适用于通用软件工程的干货.我写这篇文章是为了总 ...

  2. 在jupyter notebook中同时安装python2和python3

    环境 win10 已安装anaconda3 How 1.安装python27> conda create -n py27 python=2.72. conda install --prefix= ...

  3. 自定义notebook扩展插件_win10下jupyter notebook扩展插件安装失败

    notebook win10下jupyter notebook安装扩展插件nbextensions时,一开始提示没有权限,"erron,13"有一个json文件无法访问,后来找到c ...

  4. 多个使用idm下载器的技巧和窍门.

    如果使用了本文提供的技巧.你无疑可以将idm下载器的下载速度从一般情况的5倍提高到惊人的8倍! 1. IDM是当今互联网上最好的下载器. 2. 就功能而言,它比任何下载管理器都要好. 3. 下面,我们 ...

  5. Jupyter Notebook 如何安装 + 使用?【审核5次重磅发布】

    人生苦短 我用python 给大家介绍一下关于Jupyter Notebook的用法 关于它的组成部分就先不在这里详细解说啦~ 毕竟我可太懂你们啦~ 文章太长就会吃灰的~ 一.什么是Jupyter N ...

  6. 超好用,18 个 Jupyter Notebook 使用技巧助你快速腾飞

    Jupyter Notebook 是干嘛的就不再过多介绍了,这篇文章收集了一些顶级的 Jupyter Notebook 技巧,可以让你迅速成为一个 Jupyter 超级使用者! 作为一款完全免费的产品 ...

  7. 18 个 Jupyter Notebook 小技巧,帮助你快速腾飞

    Jupyter Notebook 是干嘛的就不再过多介绍了,这篇文章收集了一些顶级的 Jupyter Notebook 技巧,可以让你迅速成为一个 Jupyter 超级使用者! 作为一款完全免费的产品 ...

  8. 【Python】Jupyter Notebook的十大隐藏技巧--如何大大加速算法的迭代

    作者:杰少  Jupyter Notebook技巧大汇总 简 介 目前非常多的数据科学工作还是基于Notebook和Pycharm一起进行的,很多时候我们会在Notebook上面验证一些想法,然后再模 ...

  9. 1个不为人知的 Jupyter notebook 使用技巧,今天分享出来。

    Jupyter Notebook 是一个友好的 Python 编辑器,更是一款集编程和写作于一体的效率工具!最近有个小伙伴看到我的 Jupyter Notebook截图,就问为啥你没写变量名就输出结果 ...

最新文章

  1. axios解决调用后端接口跨域问题
  2. 导师吐槽大会开始:自己招的学生,哭着也要带完
  3. 自助建站软件越来越友好,三大优点值得用心体会
  4. js全局变量和局部变量
  5. C语言核心技术——函数
  6. 【BZOJ】3139: [Hnoi2013]比赛
  7. Oracle之例外(异常)
  8. 基于机器视觉的散热器钎焊缺陷检测系统研发
  9. 大数据数据库(HBase)
  10. java 修改pdf文档的页面的大小
  11. 关于awk 中如何使用 if条件判断句
  12. wkhtmltopdf下载pdf有个别字体是乱码
  13. 2020最新天猫双十一自动获取喵币
  14. 面试题大全1-javaSE部分-JavaEE框架中间件
  15. android+ue设计原则,【岗位课】移动端UI/UE设计湿
  16. 483g路由器连接服务器无响应,TP-LINK企业路由器设置 TP-LINK TL-R483 Wan口设置图文教程...
  17. 无法找到指定DLL库文件“v8.dIl“中的输出命令“Initializev8”
  18. 【通关MySQL】MySQL增删改查(CRUD)详解
  19. php读取目录中文文件名乱码解决方法
  20. google/Chrome浏览器如何查看保存在网页上的密码

热门文章

  1. TCP send 阻塞与非阻塞
  2. fiddler抓包1-抓小程序https包
  3. BZOJ 3527: [ZJOI2014]力(FFT)
  4. JDBC01 利用JDBC连接数据库【不使用数据库连接池】
  5. 斗地主你什么时候才会托管?(.NET中的托管于非托管)
  6. 记录一些容易忘记的属性 -- UITabBarController
  7. ASP.NET 3.5核心编程学习笔记(55):自定义扩展程序控件的创建
  8. Lrc歌词-开发标准 (转)
  9. 谁来代替博客园——寄生博客
  10. 真正的Google搜索