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

这篇具有很好参考价值的文章主要介绍了《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 笔记本中一些熟悉的图标、相应的菜单功能和键盘快捷键。
《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks),Python数据分析技术栈,python,数据分析,python,数据分析,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 开始,了解这种语言的核心内容。文章来源地址https://www.toymoban.com/news/detail-809067.html

到了这里,关于《Python数据分析技术栈》第01章 02 Jupyter入门(Getting started with Jupyter notebooks)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【数据分析 - 基础入门之NumPy②】Jupyter Notebook安装及使用

    大家好,我是向阳花花花花,本期给大家带来的是 Jupyter Notebook安装及使用。作者的 【 Python 数据分析】专栏正在火热更新中,如果本文对您有帮助,欢迎大家点赞 + 评论 + 收藏 ! 每日金句分享: 慢也好,步伐小也罢,是往前走就好。』—— 佚名「网易云音乐热评」 。 话

    2024年02月12日
    浏览(31)
  • 【Python爬虫与数据分析】Jupyter的安装与快捷键

    目录 一、jupyter notebook安装与配置 二、命令模式快捷键 三、编辑模式快捷键 四、文件操作 安装: Jupyter Notebook是以网页的形式打开的一个程序,集成在Anaconda包里面,也可以直接安装python3解释器,在命令行通过pip单独下载jupyter notebook程序。 通过安装Anaconda包得到的notebook可

    2024年02月13日
    浏览(26)
  • 扎实打牢数据结构算法根基,从此不怕算法面试系列之007 week01 02-07 简单的复杂度分析

    复杂度分析本身是非常理论化的一个内容,在计算机科学中,有一个专门的学科叫做—— 计算复杂性理论 。 很多童鞋看过《算法导论》,这本书的内容很多很强调算法导论。 但是实际上,对于普通程序员来说, 不需要 过度强调理论化的内容 。因为工作中更多面对的是实际

    2023年04月19日
    浏览(32)
  • Python 3 中使用 pandas 和 Jupyter Notebook 进行数据分析和可视化

    简介 Python 的 pandas 包用于数据操作和分析,旨在让您以直观的方式处理带标签或关联数据。 pandas 包提供了电子表格功能,但由于您正在使用 Python,因此它比传统的图形电子表格程序要快得多且更高效。 在本教程中,我们将介绍如何设置一个大型数据集, pandas 的 groupby() 和

    2024年02月19日
    浏览(24)
  • 【数据挖掘】使用 Python 分析公共数据【01/10】

            本文讨论了如何使用 Python 使用 Pandas 库分析官方 COVID-19 病例数据。您将看到如何从实际数据集中收集见解,发现乍一看可能不那么明显的信息。特别是,本文中提供的示例说明了如何获取有关疾病在不同国家/地区传播速度的信息。         要继续操作,您需

    2024年02月12日
    浏览(27)
  • 大数据教程【05.01】--Python 数据分析简介

    更多信息请关注WX搜索GZH:XiaoBaiGPT 本教程将介绍如何使用Python进行大数据分析。Python是一种功能强大且易于使用的编程语言,具备丰富的数据分析库和工具。在本教程中,我们将涵盖以下主题: 数据分析准备工作 导入数据 数据清洗和预处理 数据探索与可视化 数据分析与建

    2024年02月08日
    浏览(22)
  • python数据分析-matplotlib散点图-条形图的绘制以及完整方法归纳02

    散点图的绘制使用的是scatter()方法,传入的参数也是两个列表,分别为x,y坐标轴的值使用散点图可以显示若干数列序列中各数值之间是否存在相关性. 1.导入模块 from matplotlib import pyplot as plt import matplotlib 2.设置散点图所有字符的字体样式 matplotlib.rcParams[‘font.family’] = ‘Microsof

    2023年04月11日
    浏览(18)
  • 【spark大数据】spark大数据处理技术入门项目--购物信息分析

    购物信息分析基于spark 目录 本案例中三个文案例中需要处理的文件为 order_goods.txt、products.txt 以及 orders.txt 三个文件,三个文件的说明如下 一、本实训项目针对实验数据主要完成了哪些处理? 二、Hadoop+Spark集群环境的搭建步骤有哪些?(只介绍完全分布式集群环境的搭建)

    2023年04月08日
    浏览(29)
  • 数据分析之jupyter notebook工具

    1、简介 Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果。——Jupyter Notebook官方介绍 简而言之,Jupyter Notebook是以网页的形式打开,可以在网页页面中直接编写代码和运行代码,代码的运行结果也会直接在

    2024年02月16日
    浏览(25)
  • 【数据分析入门】人工智能、数据分析和深度学习是什么关系?如何快速入门 Python Pandas?

    本文详细介绍了人工智能、数据分析和深度学习之间的关系,并就数据分析所需的Pandas库做了胎教般的入门引导。祝读得开心!   本文是原 《数据分析大全》 、现改名为 《数据分析》 专栏的第二篇,我在写这篇文章的时候突然意识到—— 单靠我是不可能把数据分析的方

    2024年02月14日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包