iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 1
2
AI & Data

Hands on Data Cleaning and Scraping 資料清理與爬蟲實作系列 第 1

Day01 Jupyter Notebook. Jupyter Notebook基本安裝與操作

  • 分享至 

  • xImage
  •  

此篇參考並縮寫幾個覺得寫得很詳細完整的教學,文內附上連結與出處。

Brief Introduction 簡介

Jupyter Notebook是一個介於編輯器及IDE之間的應用環境,能以網頁形式,讓使用者在瀏覽器中以互動式計算的方式,撰寫及執行程式碼。加上容易呈現資料視覺化的執行、易於分享等諸多優點,許多資料分析、機器學習的討論都會以Jupyter Notebook的形式呈現。

Jupyter Notebook is kind of an inbetween of a text editor and IDE. It is web-based and let users write and run codes easily with an intuitive way with it’s interactive computing system and the ability to instantly show results. Furthermore, it’s also super easy to visualize data and to share. With all these merits mentioned above and many others, many people in the field of Data Science and Machine Learning use it to share thoughts and communicate.

Installation 安裝

安裝Jupyter Notebook步驟:

  1. 先安裝Python(Python3.3及更高版本或Python2.7)
  2. 選擇使用Anaconda安裝或使用pip安裝
    官方強烈建議使用Anaconda安裝,主要原因是Anaconda包含許多資料科學所需要用到的套件,已有大師寫過詳盡鉅細靡遺的安裝教程,深感難以超越,附上傳送門

Steps of installing Jupyter Notebook:

  1. First, you’ll need to install Python (Python2.7 / 3.3 or above).
  2. Installing using Anaconda (recommended, because it contains many needed packages for data analysis) or pip install (slightly different depends on which version of Python you are using). There are many existed Anaconda installation tutorials online so no need to write another.

Basics 基本操作

安裝完成後,就可以從Windows開始選單中點選開啟Jupyter Notebook。
After installing Anaconda, now you can start Jupyter Notebook in Windows from Start.
https://ithelp.ithome.com.tw/upload/images/20190902/20119709s0naBC6jk5.png

運行介面如下,點選New並選擇Python 3開始一個新的檔案。
The interface is as below, click New and choose Python 3 to start a new file.
https://ithelp.ithome.com.tw/upload/images/20190902/2011970923SFmvGGT1.png

Jupyter Notebook的編輯介面主要有下面四部分:
File Name 檔名(點擊即可重新命名)、Menu 主選單、Toolbar 工具列、Cell 編輯單元。工具列右側有一個下拉選單能選擇目前要增加的Cell模式,介紹常用兩種:

  1. Code Cell 用以撰寫並執行程式碼,並在下方呈現其執行結果。
  2. Markdown Cell 則是可以放一些文字、圖片、表格等,傳送門

There are 4 main sections in Jupyter Notebook, File Name (click on it to rename), Menu, Toolbar, and Cell. On the right side of the toolbar, there is a drop down menu to change the mode of cell you’re now adding. Two frequently used are:

  1. Code Cell: contains code to be executed in the kernel and displays its output below.
  2. Markdown Cell: contains text, images, tables, calculas, and many more.
    https://ithelp.ithome.com.tw/upload/images/20190902/20119709zoEpi2sMEr.png

各功能說明如圖所示:

Functions of buttons:
https://ithelp.ithome.com.tw/upload/images/20190902/20119709v6f1QcH4D7.png
命令模式(如上圖藍色框框)、編輯模式(如下圖綠色框框)
Command Mode (shown as above in blue square), Edit Mode (shown as below in green square)
https://ithelp.ithome.com.tw/upload/images/20190902/20119709Ej42DT8pbN.png

Executing 執行程式碼
Cell選單下拉會看見不同執行方式,執行前可以稍微注意一下目前選定的是哪個Cell。個人習慣使用(Ctrl + Enter)執行當前Cell並進入命令模式,(Alt + Enter)執行所有當前Cell並在下方新增一個Cell。
Under the drop down menu of Cell, there are different ways to run Cells. Better check you are selecting the cell that you want to run before doing it. Personally I prefer to use hot keys - Ctrl+Enter to run the selected cell and enter command mode; Alt+Enter to run the current cell and inserts a new one below.
https://ithelp.ithome.com.tw/upload/images/20190902/20119709AlIJqe3JxY.png

附上圖片來源、介面完整介紹以及其他操作解說傳送門

題外話,在查找資料時才知道原來Jupyter Notebook的名子是結合其支持的三種核心程式語言Julia、Python和R。
Just found out that the name of Jupyter Notebook comes from the three main languages it supports - Julia, Python, and R, while looking up information for this article.

文中若有錯誤還望不吝指正,感激不盡。
Please let me know if there’s any mistake in this article. Thanks for reading.

Reference 參考資料:

[1] Jupyter Notebook介紹

[2] 資料分析&機器學習 第1.2講:Jupyter Notebook介紹

[3] Jupyter Notebook for Beginners: A Tutorial

[4] Jupyter Notebook介绍、安装及使用教程

[5] Anaconda介紹及安裝教學

[6] 圖片來源

[7] 2. Markdown & LaTeX - Jupyter Tutorial (IPython 3)

[8] The Jupyter Notebook

[9] 用 Markdown 做筆記


下一篇
Day02 What is EDA (Exploratory Data Analysis)? 淺談何謂探索式資料分析
系列文
Hands on Data Cleaning and Scraping 資料清理與爬蟲實作30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言