Home
About
Contact
Home-icon
Python 新手村
_環境設定 & 安裝教學
__JupyterLab
__Anaconda
__PyCharm
_Python 基礎教學
__1. Python介紹 + 資料型態
__2. 流程控制及迴圈
__3. 字串處理
__4. Function 函數
__5. Exception handling 例外處理
__6. 輸出 and 輸入
__7. 標準函數庫及模組
_Python Library
__Matplotlib 介紹
__Seaborn 介紹
__Scikit-Learn 介紹
_Python Tips
__Python Tips: Ignore warning 忽略警告
__Python Tips: loc和iloc的差別
__Python Tips: and, or, &, | 的差別
__Python Tips: 獲取 API 資料
__Python Tips: 讀取 & 輸出 CSV 教學
Data Engineering
_環境設定 (Docker 介紹)
__Docker Introduction
__Dockerfile 和 docker-compose.yml 範例
__GIT Introduction
_DE Project 1 - ETL
__DE Project 1 - ETL - 環境設定
__DE Project 1 - ETL - AirFlow 設定
Documentation
_Web Documentation
_Video Documentation
首頁
Tips
Python Tips: loc和iloc的差別
Python Tips: loc和iloc的差別
by -
Killer01
on -
10月 06, 2018
很多初學者可能對loc和iloc的功能感到困擾, 下面是這兩個指令的一個簡單說明.
我們先建立一個 population 和 area 的dadaframe, 並且設定 index 為州名, 如上圖所示.
如果要從上述的資料做一個資料切片, 可以使用 loc 或 iloc 兩個方法; 其中的差別在於 loc 的參數為index的名稱, 而 iloc 則是 index 的行數. 如下圖例, 我要取出 Texas 的資料, 使用loc指令搭配的參數值為 Texas; 如果使用 iloc, 則參數值為 1.
當然, 如果要取出多筆資料, 也可以使用如下的方法.
希望以上說明, 對你有幫助!
張貼留言
0 留言
Popular Posts
瀏覽人數
站內搜尋
Archive
Archive
1月 2024 (9)
1月 2021 (1)
10月 2018 (4)
9月 2018 (2)
5月 2018 (1)
1月 2018 (2)
12月 2017 (5)
Follow Me!
技術提供:Blogger
0 留言