当前位置: 首页 > news >正文

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

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 开始,了解这种语言的核心内容。

相关文章:

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

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…...

【征服redis5】redis的Redisson客户端

目录 1 Redisson介绍 2. 与其他Java Redis客户端的比较 3.基本的配置与连接池 3.1 依赖和SDK 3.2 配置内容解析 4 实战案例:优雅的让Hash的某个Field过期 5 Redisson的强大功能 1 Redisson介绍 Redisson 最初由 GitHub 用户 “mrniko” 创建,并在…...

React16源码: React中的beginWork的源码实现

beginWork 1 )概述 在 renderRoot 之后,要对我们的 Fiber 树每一个节点进行对应的更新更新节点的一个入口方法,就是 beginWork这个入口方法会有帮助我们去优化整棵树的更新过程 react 它的节点其实是非常多的,如果每一次子节点的…...

5-微信小程序语法参考

1. 数据绑定 官网传送门 WXML 中的动态数据均来自对应 Page 的 data。 数据绑定使用 Mustache 语法&#xff08;双大括号&#xff09;将变量包起来 ts Page({data: {info: hello wechart!,msgList: [{ msg: hello }, { msg: wechart }]}, })WXML <view class"vie…...

数组练习 Leetcode 566.重塑矩阵

在 MATLAB 中&#xff0c;有一个非常有用的函数 reshape &#xff0c;它可以将一个 m x n 矩阵重塑为另一个大小不同&#xff08;r x c&#xff09;的新矩阵&#xff0c;但保留其原始数据。 给你一个由二维数组 mat 表示的 m x n 矩阵&#xff0c;以及两个正整数 r 和 c &#…...

Linux centos中find命令的多种用途:按照具体应用来详细说明find的用法举例

目录 一、find命令 二、find命令的语法 &#xff08;一&#xff09;语法格式 &#xff08;二&#xff09;选项 1、选项(option)介绍 2、控制符号链接的option 3、调试选项debugopts 4、优化选项 &#xff08;三&#xff09;表达式expression 1、选项options 2、测试…...

服务器数据恢复—OceanStor存储raid5热备盘同步数据失败的数据恢复案例

服务器数据恢复环境&#xff1a; 华为OceanStor某型号存储&#xff0c;存储内有一组由24块硬盘组建的raid5阵列&#xff0c;配置1块热备盘。 服务器故障&#xff1a; 该存储raid5阵列中有一块硬盘离线&#xff0c;热备盘自动激活并开始同步数据&#xff0c;在热备盘同步数据的…...

Xline v0.6.1: 一个用于元数据管理的分布式KV存储

Xline是什么&#xff1f;我们为什么要做Xline&#xff1f; Xline是一个基于Curp协议的&#xff0c;用于管理元数据的分布式KV存储。现有的分布式KV存储大多采用Raft共识协议&#xff0c;需要两次RTT才能完成一次请求。当部署在单个数据中心时&#xff0c;节点之间的延迟较低&a…...

【CSS】解决height = line-height 文字不垂直居中(偏上、偏下)的问题

解决办法1&#xff1a; 查看 font-family 属性&#xff0c;确认是否是因为字体而导致的不垂直居中问题。 其他小知识&#xff1a; 基线就是小写x字母的下边缘(线) 就是我们常说的 基线。line-height 属性设置的行高也就是定义的两行文字基线之间的距离! 参考文章&#xff1a;…...

天津想转行学python培训班靠谱吗?

现在的职业如此繁多&#xff0c;很多人把高薪当成衡量工作好坏的重要标准&#xff0c;因此IT行业以超出其他行业几倍薪资水平成为不错的选择&#xff0c;而Python又以其简单易学好上手成为大家所青睐的学习目标。 Python发展前景如何 Python语言就业发展方向广泛&#xff1a;…...

(C语言)冒泡排序

一、运行结果&#xff1b; 二、源代码&#xff1b; # define _CRT_SECURE_NO_WARNINGS # include <stdio.h>//实现buble_sort函数&#xff1b; void buble_sort(int arr[], int sz) {//初始化变量值&#xff1b;int i 0;//嵌套循环冒泡排序&#xff1b;//外层循环&…...

怎么样的布局是符合可制造性的PCB布局?

满足可制造性、可装配性、可维修性要求&#xff0c;方便调试的时候于检测和返修&#xff0c;能够方便的拆卸器件&#xff1a; 1&#xff09;极性器件的方向不要超过2种&#xff0c;最好都进行统一方向等要求&#xff0c;如图1-1所示&#xff1b; 图1-1 极性器件方向统一摆放 2…...

第28关 k8s监控实战之Prometheus(九)

------> 课程视频同步分享在今日头条和B站 大家好&#xff0c;我是博哥爱运维。早期我们经常用邮箱接收报警邮件&#xff0c;但是报警不及时&#xff0c;而且目前各云平台对邮件发送限制还比较严格&#xff0c;所以目前在生产中用得更为多的是基于webhook来转发报警内容到企…...

安全防御之可信计算技术

可信计算技术是一种计算机安全体系结构&#xff0c;旨在提高计算机系统在面临各种攻击和威胁时的安全性和保密性。它通过包括硬件加密、受限访问以及计算机系统本身的完整性验证等技术手段&#xff0c;确保计算机系统在各种攻击和威胁下保持高度安全和保密性。 一、可信计算基…...

FPGA引脚物理电平(内部资源,Select IO)-认知2

引脚电平 The SelectIO pins can be configured to various I/O standards, both single-ended and differential. • Single-ended I/O standards (e.g., LVCMOS, LVTTL, HSTL, PCI, and SSTL) • Differential I/O standards (e.g., LVDS, Mini_LVDS, RSDS, PPDS, BLVDS, and…...

PBR材质纹理下载

03:10 按照视频里的顺序 我们从第6个网站开始倒数 点击本行文字或下方链接 进入查看 6大网站地址 网址查看链接&#xff1a; http://www.uzing.net/community_show-1962-48-48-35.html 06 Tectures Wood Fence 001 | 3D TEXTURES 简介&#xff1a;最大的纹理网站之一&#x…...

mac PyCharm 使用conda环境

1 使用conda创建虚拟环境 conda create -n test6 python3.9 -y conda activate test62 选择conda环境 本地 选择已经存在的conda环境 右下角会显示现在的环境。...

10个常用的正则表达式

1 电话号码 let r1 /^1[3-9]\d{9}$/g console.log(r1.exec(18596932371)) 2 qq号 let r2 /^[1-9][0-9]{4,9}$/g console.log(r2.exec(123456)) 3 十六进制的方式表示颜色 let r3 /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/g // # 可能可有可无&#xff0c;如果不需要#&a…...

对一手游的自定义 luajit 字节码的研究

对一手游的自定义 luajit 字节码的研究 前言 最近闲下来之后无聊研究起了一个unity手游 大量使用了 lua &#xff08;或者说就是 lua 写的 &#xff09; 看到网上已有的一些针对方案 都觉得太不方便 于是深入研究了一下 他自定义的 luajit 情况研究 首先 这是一个 unity的 传…...

1125. 牛的旅行 (Floyd算法,最短路)

1125. 牛的旅行 - AcWing题库 农民John的农场里有很多牧区&#xff0c;有的路径连接一些特定的牧区。 一片所有连通的牧区称为一个牧场。 但是就目前而言&#xff0c;你能看到至少有两个牧区不连通。 现在&#xff0c;John想在农场里添加一条路径&#xff08;注意&#xff…...

浅谈 React Hooks

React Hooks 是 React 16.8 引入的一组 API&#xff0c;用于在函数组件中使用 state 和其他 React 特性&#xff08;例如生命周期方法、context 等&#xff09;。Hooks 通过简洁的函数接口&#xff0c;解决了状态与 UI 的高度解耦&#xff0c;通过函数式编程范式实现更灵活 Rea…...

Flask RESTful 示例

目录 1. 环境准备2. 安装依赖3. 修改main.py4. 运行应用5. API使用示例获取所有任务获取单个任务创建新任务更新任务删除任务 中文乱码问题&#xff1a; 下面创建一个简单的Flask RESTful API示例。首先&#xff0c;我们需要创建环境&#xff0c;安装必要的依赖&#xff0c;然后…...

从WWDC看苹果产品发展的规律

WWDC 是苹果公司一年一度面向全球开发者的盛会&#xff0c;其主题演讲展现了苹果在产品设计、技术路线、用户体验和生态系统构建上的核心理念与演进脉络。我们借助 ChatGPT Deep Research 工具&#xff0c;对过去十年 WWDC 主题演讲内容进行了系统化分析&#xff0c;形成了这份…...

在rocky linux 9.5上在线安装 docker

前面是指南&#xff0c;后面是日志 sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo sudo dnf install docker-ce docker-ce-cli containerd.io -y docker version sudo systemctl start docker sudo systemctl status docker …...

《Playwright:微软的自动化测试工具详解》

Playwright 简介:声明内容来自网络&#xff0c;将内容拼接整理出来的文档 Playwright 是微软开发的自动化测试工具&#xff0c;支持 Chrome、Firefox、Safari 等主流浏览器&#xff0c;提供多语言 API&#xff08;Python、JavaScript、Java、.NET&#xff09;。它的特点包括&a…...

论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)

笔记整理&#xff1a;刘治强&#xff0c;浙江大学硕士生&#xff0c;研究方向为知识图谱表示学习&#xff0c;大语言模型 论文链接&#xff1a;http://arxiv.org/abs/2407.16127 发表会议&#xff1a;ISWC 2024 1. 动机 传统的知识图谱补全&#xff08;KGC&#xff09;模型通过…...

今日科技热点速览

&#x1f525; 今日科技热点速览 &#x1f3ae; 任天堂Switch 2 正式发售 任天堂新一代游戏主机 Switch 2 今日正式上线发售&#xff0c;主打更强图形性能与沉浸式体验&#xff0c;支持多模态交互&#xff0c;受到全球玩家热捧 。 &#x1f916; 人工智能持续突破 DeepSeek-R1&…...

selenium学习实战【Python爬虫】

selenium学习实战【Python爬虫】 文章目录 selenium学习实战【Python爬虫】一、声明二、学习目标三、安装依赖3.1 安装selenium库3.2 安装浏览器驱动3.2.1 查看Edge版本3.2.2 驱动安装 四、代码讲解4.1 配置浏览器4.2 加载更多4.3 寻找内容4.4 完整代码 五、报告文件爬取5.1 提…...

OPenCV CUDA模块图像处理-----对图像执行 均值漂移滤波(Mean Shift Filtering)函数meanShiftFiltering()

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 在 GPU 上对图像执行 均值漂移滤波&#xff08;Mean Shift Filtering&#xff09;&#xff0c;用于图像分割或平滑处理。 该函数将输入图像中的…...

C# 求圆面积的程序(Program to find area of a circle)

给定半径r&#xff0c;求圆的面积。圆的面积应精确到小数点后5位。 例子&#xff1a; 输入&#xff1a;r 5 输出&#xff1a;78.53982 解释&#xff1a;由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982&#xff0c;因为我们只保留小数点后 5 位数字。 输…...