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的编码体验。
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笔记本计算机单元的执行时间。 它计算墙壁时间 ,可以将其称为执行该单元所需的总时间。
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 tqdmOr 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函数,其用法和实现如下所示:
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_blackUsage for Jupyter Notebook:
Jupyter Notebook的用法:
%load_ext nb_black (Image by Author), Unformatted cell (作者提供的图片),未格式化的单元格 (Image by Author), Formatted cell using nb_black (作者提供的图像),使用nb_black格式化的单元格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并运行单元。
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函数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-up或arrow-down键向上或向下滚动菜单。 您也可以使用鼠标滚动。 单击关键字或在选定的关键字上按Enter键以确认您的建议。
You will also get suggestions for custom functions and variables.
您还将获得有关自定义函数和变量的建议。
(Image by Author), Suggestions from the pandas package (作者提供的图片),来自熊猫包装的建议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 (按作者显示),点击面板左侧以更改输出屏幕的视图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将运行当前单元格并插入一个新单元格并突出显示它。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) 来源 )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与内核名称一起使用:
%