《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks)

news2024/9/28 19:21:47

02 Jupyter入门(Getting started with Jupyter notebooks)

《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks)

Before we discuss the essentials of Jupyter notebooks, let us discuss what an integrated development environment (or IDE) is. An IDE brings together the various activities involved in programming, like including writing and editing code, debugging, and creating executables. It also includes features like autocompletion (completing what the user wants to type, thus enabling the user to focus on logic and problem-solving) and syntax highlighting (highlighting the various elements and keywords of the language). There are many IDEs for Python, apart from Jupyter, including Enthought Canopy, Spyder, PyCharm, and Rodeo. There are several reasons for Jupyter becoming a ubiquitous, de facto standard in the data science community. These include ease of use and customization, support for several programming languages, platform independence, facilitation of access to remote data, and the benefit of combining output, code, and multimedia under one roof.

在讨论 Jupyter 笔记本的要点之前,让我们先讨论一下什么是集成开发环境(或 IDE)。集成开发环境汇集了编程过程中涉及的各种活动,如编写和编辑代码、调试和创建可执行文件。它还包括自动完成(完成用户想要输入的内容,从而使用户能够专注于逻辑和解决问题)和语法高亮(高亮显示语言的各种元素和关键字)等功能。除了 Jupyter 之外,还有许多 Python 集成开发环境,包括 Enthought Canopy、Spyder、PyCharm 和 Rodeo。Jupyter 成为数据科学界无处不在的事实标准有几个原因。这些原因包括:易于使用和定制、支持多种编程语言、平台独立性、便于访问远程数据,以及将输出、代码和多媒体整合在一个屋檐下的好处。

JupyterLab is the IDE for Jupyter notebooks. Jupyter notebooks are web applications that run locally on a user’s machine. They can be used for loading, cleaning, analyzing, and modeling data. You can add code, equations, images, and markdown text in a Jupyter notebook. Jupyter notebooks serve the dual purpose of running your code as well as serving as a platform for presenting and sharing your work with others. Let us look at the various features of this application.

JupyterLab 是 Jupyter 笔记本的集成开发环境。Jupyter 笔记本是在用户机器上本地运行的网络应用程序。它们可用于加载、清理、分析和建模数据。您可以在 Jupyter 笔记本中添加代码、方程式、图像和标记文本。Jupyter 笔记本具有双重用途,既可以运行代码,也可以作为与他人展示和分享工作的平台。让我们来看看这款应用程序的各种功能。

基本用法

打开面板(Opening the dashboard)

Type “jupyter notebook” in the search bar next to the start menu. This will open the Jupyter dashboard. The dashboard can be used to create new notebooks or open an existing one.

在开始菜单旁边的搜索栏中输入 “jupyter notebook”。这将打开 Jupyter 面板。仪表板可用于创建新笔记本或打开现有笔记本。

创建新的笔记(Creating a new notebook)

Create a new Jupyter notebook by selecting New from the upper right corner of the Jupyter dashboard and then select Python 3 from the drop-down list that appears, as shown in Figure 1-3.

如图 1-3 所示,从 Jupyter 面板右上角选择新建,然后从出现的下拉列表中选择 Python 3,创建一个新的 Jupyter 笔记本。

添加要执行的代码(Entering and executing code)

Click inside the first cell in your notebook and type a simple line of code, as shown in Figure 1-4. Execute the code by selecting Run Cells from the “Cell” menu, or use the shortcut keys Ctrl+Enter.

单击笔记本中的第一个单元格,输入一行简单的代码,如图 1-4 所示。从 "单元格 "菜单中选择 "运行单元格 "或使用快捷键 Ctrl+Enter 执行代码。

print("Hello World")

添加MarkDown文本(Adding markdown text or headings)

In the new cell, change the formatting by selecting Markdown as shown in Figure 1-5, or by pressing the keys Esc+M on your keyboard. You can also add a heading to your Jupyter notebook by selecting Heading from the drop-down list shown in the following or pressing the shortcut keys Esc+(1/2/3/4).

在新单元格中,选择 Markdown(如图 1-5 所示)或按键盘上的快捷键 Esc+M,更改格式。您还可以从下拉列表中选择标题或按快捷键 Esc+(1/2/3/4),为 Jupyter 笔记本添加标题。

重命名笔记(Renaming a notebook)

Click the default name of the notebook and type a new name, as shown in Figure 1-6.

单击笔记本的默认名称并键入新名称,如图 1-6 所示。

You can also rename a notebook by selecting File ➤ Rename.

您还可以通过选择文件 ➤ 重命名来重新命名笔记本。

保存笔记(Saving a notebook)

Press Ctrl+S or choose File ➤ Save and Checkpoint.

按 Ctrl+S 或选择文件 ➤ 保存和检查点。

下载笔记(Downloading the notebook)

You can email or share your notebook by downloading your notebook using the option File ➤ Download as ➤ notebook (.ipynb), as shown in Figure 1-7.

如图 1-7 所示,您可以使用 "文件"➤"下载为➤笔记本(.ipynb)"选项下载笔记本,通过电子邮件发送或共享笔记本。

Jupyter 中的快捷方式和其他功能(Shortcuts and other features in Jupyter)

Let us look at some key features of Jupyter notebooks, including shortcuts, tab completions, and magic commands.

让我们看看 Jupyter 笔记本的一些关键功能,包括快捷方式、选项卡补全和神奇命令。

Table 1-1 gives some of the familiar icons found in Jupyter notebooks, the corresponding menu functions, and the keyboard shortcuts.

表 1-1 列出了 Jupyter 笔记本中一些熟悉的图标、相应的菜单功能和键盘快捷键。
在这里插入图片描述

If you are not sure about which keyboard shortcut to use, go to: Help ➤ Keyboard Shortcuts, as shown in Figure 1-8.

如果不确定使用哪个键盘快捷键,请转到 帮助 ➤ 键盘快捷键,如图 1-8 所示。

Commonly used keyboard shortcuts include

  • Shift+Enter to run the code in the current cell and move to the next cell.
  • Esc to leave a cell.
  • Esc+M changes the mode for a cell to “Markdown” mode.
  • Esc+Y changes the mode for a cell to “Code”

常用的快捷键包括

  • Shift+Enter 运行当前单元格中的代码并移动到下一单元格。
  • Esc 离开单元格。
  • Esc+M 可将单元格模式更改为 "Markdown "模式。
  • Esc+Y 可将单元格模式更改为 "代码 "模式。

使用tab提示(Tab Completion)

This is a feature that can be used in Jupyter notebooks to help you complete the code being written. Usage of tab completions can speed up the workflow, reduce bugs, and quickly complete function names, thus reducing typos and saving you from having to remember the names of all the modules and functions.

这是一项可用于 Jupyter 笔记本的功能,可帮助您完成正在编写的代码。使用制表符补全可以加快工作流程,减少错误,并快速补全函数名称,从而减少错别字,免去记住所有模块和函数名称的麻烦。

For example, if you want to import the Matplotlib library but don’t remember the spelling, you could type the first three letters, mat, and press Tab. You would see a dropdown list, as shown in Figure 1-9. The correct name of the library is the second name in the drop-down list.

例如,如果想导入 Matplotlib 库,但不记得拼写,可以键入前三个字母 mat,然后按 Tab 键。你会看到一个下拉列表,如图 1-9 所示。该库的正确名称是下拉列表中的第二个名称。

Jupyter 中使用的神奇命令(Magic commands used in Jupyter)

Magic commands are special commands that start with one or more % signs, followed by a command. The commands that start with one % symbol are applicable for a single line of code, and those beginning with two % signs are applicable for the entire cell (all lines of code within a cell).

魔法命令是一种特殊命令,以一个或多个 % 符号开头,后面跟一个命令。以一个 % 符号开头的命令适用于一行代码,而以两个 % 符号开头的命令适用于整个单元格(单元格内的所有代码行)。

One commonly used magic command, shown in the following, is used to display Matplotlib graphs inside the notebook. Adding this magic command avoids the need to call the plt.show function separately for showing graphs (the Matplotlib library is discussed in detail in Chapter 7).

一个常用的神奇命令如下所示,用于在笔记本中显示 Matplotlib 图形。添加该神奇命令后,就无需单独调用 plt.show 函数来显示图形了(第 7 章将详细讨论 Matplotlib 库)。

%matplotlib inline

Magic commands, like timeit, can also be used to time the execution of a script, as shown in the following.

魔法命令(如 timeit)也可用于为脚本的执行计时,如下所示。

%%timeit
for i in range(100000):
  i*i

Output:

16.1 ms ± 283 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Now that you understand the basics of using Jupyter notebooks, let us get started with Python and understand the core aspects of this language.

现在,您已经了解了使用 Jupyter 笔记本的基础知识,让我们从 Python 开始,了解这种语言的核心内容。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1396418.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言编译和链接

翻译环境和运行环境 在ANSI C的任何一种实现中,存在两个不同的环境 .第一种是翻译环境,在这个环境中源代码被转换为可执行的机器指令 .第二种是执行环境,它用于实际执行代码 翻译环境 翻译环境是由编译和链接两个大过程组成,而…

仿真机器人-深度学习CV和激光雷达感知(项目2)day03【机器人简介与ROS基础】

文章目录 前言机器人简介机器人应用与前景机器人形态机器人的构成 ROS基础ROS的作用和特点ROS的运行机制ROS常用命令 前言 💫你好,我是辰chen,本文旨在准备考研复试或就业 💫本文内容是我为复试准备的第二个项目 💫欢迎…

RT-Thread 瑞萨 智能家居网络开发:RA6M3 HMI Board 以太网+GUI技术实践

不用放大了, 我在包里找到张不小的…… 以太网HMI线下培训-环境准备 名字虽然叫技术培训: 其实是由两部分组成:板子网关 先介绍周六的培训是啥,然后再介绍一下要准备的一些东西 R A 6 M 3 H M I − B o a r d \textcolor{#41…

AD导出BOM表 导出PDF

1.Simple BOM: 这种模式下,最好在pcb界面,这样的导出的文件名字是工程名字,要是在原理图界面导出,会以原理图的名字命名表格。 直接在菜单栏 报告->Simple BOM 即可导出物料清单,默认导出 comment pattern qu…

LaTeX-OCR安装教程

一. 通用安装步骤 1.前置应用 安装LaTeX-OCR首先需要安装Python。在系统自带的应用商店Microsoft Store搜索Python,点击最新版本Python 3.12下载即可。 2.运行powershell Win11按底部状态栏windows徽标在搜索框内搜索 powershell 或者按快捷键 “win 键 R” &am…

GO基础进阶篇 (十四)、Http编程

Web基础概念 web应用程序 web程序可以提供浏览器访问的程序。Web应用程序通常采用客户端-服务器模型。客户端是用户使用的Web浏览器或其他Web客户端,而服务器是存储和处理数据的远程计算机。 我们能访问到的任何一个页面或资源,都存在于世界的某一个角落…

linux文件比较工具diff-关于参数-pN的设置方法

非纯文本文件比较可用cmp命令 第一:利用diff创建分析文件,处理补丁(patch)功能的文件 案例:多数用于同一软件的不同版本之间,比如比较配置文件和源文件的区别,生成补丁文件,执行更…

java结合百度ocr实现图片文字提取功能

1.进入百度云控制台&#xff0c;找到文字识别服务&#xff0c;创建一个应用 2.引入ocr需要的maven依赖包 <dependency><groupId>com.baidu.aip</groupId><artifactId>java-sdk</artifactId><version>4.16.11</version> </depend…

linux 安装ffmpeg

一、下载 ffmpeg-4.3.1 下载地址&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1xbkpHDfIWSCbHFGJJHSQcA 提取码&#xff1a;3eil 二、上传到服务器root目录下 三、给ffmpeg-4.3.1 读写权限 chmod -R 777 /root/ffmpeg-4.3.1 四、创建软连接 1.进入/bin 目录 2.…

Linux--磁盘与文件系统

目录 1.什么是文件系统 2.磁盘 2.1什么时磁盘 2.2磁盘的物理存储结构 2.3磁盘的逻辑抽象结构 3.磁盘文件系统&#xff08;EXT2&#xff09; inode Table(i结点表) Data Block inode Bitmap(inode位图) Block Bitmap(块位图) 在Linux如何删除文件 Group Descriptor Ta…

【Maven】—— SSM分模块开发

目录 一、分模块开发意义 二、示例 1、新建模块 2、书写模块代码 3、通过maven指令安装模块到本地仓库 三、可选依赖 四、排除依赖 五、聚合 使用 1、新建一个新的模块 2、设置打包类型为pom 3、设置所包含的子模块名称 六、继承 1、新建模块&#xff0c;设置打包…

dp专题15 零钱兑换

本题链接&#xff1a;力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台 题目&#xff1a; 思路&#xff1a; 这道题&#xff0c;是个比较模板的完全背包问题&#xff0c;这里要求的是问凑成总金额所需的最少的硬币的个数。 我们明确一下 dp[ …

红队打靶练习:BOB: 1.0.1

目录 信息收集 1、netdiscover 2、nmap 3、nikto 4、whatweb 目录探测 1、dirb 2、gobuster 3、dirsearch WEB 主页&#xff1a; robots.txt 其他页面 反弹shell 提权 系统信息收集 jc账户 本地提权 信息收集 1、netdiscover ┌──(root㉿ru)-[~/kali] └…

「JavaSE」类和对象3

&#x1f387;个人主页&#xff1a;Ice_Sugar_7 &#x1f387;所属专栏&#xff1a;快来卷Java啦 &#x1f387;欢迎点赞收藏加关注哦&#xff01; 类和对象3 &#x1f349;多态&#x1f34c;重写&#x1f34c;向上转型&向下转型&#x1f34c;静态绑定&动态绑定&#x…

Docker 安装 CentOS

Docker 安装 CentOS CentOS&#xff08;Community Enterprise Operating System&#xff09;是 Linux 发行版之一&#xff0c;它是来自于 Red Hat Enterprise Linux(RHEL) 依照开放源代码规定发布的源代码所编译而成。由于出自同样的源代码&#xff0c;因此有些要求高度稳定性…

【Docker】在centos中安装nginx

&#x1f389;&#x1f389;欢迎来到我的CSDN主页&#xff01;&#x1f389;&#x1f389; &#x1f3c5;我是平顶山大师&#xff0c;一个在CSDN分享笔记的博主。&#x1f4da;&#x1f4da; &#x1f31f;推荐给大家我的博客专栏《【Docker】安装nginx》。&#x1f3af;&#…

16.云原生之kubesphere组件安装卸载

云原生专栏大纲 文章目录 KubeSphere组件介绍KubeSphere组件安装卸载配置内容参考安装组件步骤卸载组件步骤 KubeSphere组件介绍 KubeSphere 的全部可插拔组件如下&#xff1a; 配置项功能组件描述alertingKubeSphere 告警系统可以为工作负载和节点自定义告警策略。告警策略…

WordPress后台底部版权信息“感谢使用 WordPress 进行创作”和版本号怎么修改或删除?

不知道各位WordPress站长在后台操作时&#xff0c;是否有注意到每一个页面底部左侧都有一个“感谢使用 WordPress 进行创作。”&#xff0c;其中WordPress还是带有nofollow标签的链接&#xff1b;而页面底部右侧都有一个WordPress版本号&#xff0c;如下图中的“6.4.2 版本”。…

海盗王NPC出售物品解析器

在编辑或者查看NPC出售物品的时候&#xff0c;需要了解它到底出售了那些物品。 当物品很多的时候&#xff0c;就很难一个一个地去查了。 想到之前有做过一个物品编辑器&#xff0c;于是就想在那个基础上再增加一个NPC物品分析器功能。 实现如下&#xff1a; 将NPC的出售列表直接…