---
# System prepended metadata

title: Pandas Data frame of Python
tags: [package, numpy, Data Frame, pip, python]

---

Pandas Data frame of Python
===
王辰禎, DCT, NTCU(Taiwan)
---
###### tags: `python` `package` `package` `pip` `Data Frame` `numpy`
**資料科學與問題解決week04HW(3/14) : 課本作業p2-25 習題3**
[Golab 程式碼](https://colab.research.google.com/drive/1mJgTJ98sDZow7w_h7kny9Ue0fowhC1qU?usp=sharing)

---
#### **If you use python IDLE from python.org, you should use CMD and pip to install the pandas package.**
![01_error](https://hackmd.io/_uploads/rJ9X-3EC6.png)
##### 用命令提示字元確認python與pip的版本，讀不到請參考以下影片處理 
語法:`pip -V`、`python -V`或`pip --version`
![02_checkPythonPipAndUsePipInstallPandasPackage](https://hackmd.io/_uploads/BkzPz3ECa.png)
<iframe width="560" height="315" src="https://www.youtube.com/embed/FYkOr_7hOXw?si=yeAgmPRfW8YJsJDr" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

##### install the pandas package
1. open the cmd(命令提示字元)
2. 輸入 `pip install pandas`

![螢幕擷取畫面 2024-04-04 081025](https://hackmd.io/_uploads/B1UzxuikC.png)

---
#### <正文>import(匯入)套件，e.g. random、math套件等等
![image](https://hackmd.io/_uploads/By5CJacegl.png)


---
#### 將題目的資料丟進Data Frame，並加上index
![image](https://hackmd.io/_uploads/SkRkea9ggx.png)

---
#### 1.將English中'90'改為90。
![image](https://hackmd.io/_uploads/S1l-xacelx.png)

將該格轉成數值型態int([內容])
用type()確認型態是否轉變
輸出Data Frame

---
#### 2.將History中的188改為88
兩種方法抓Data Frame的某值(某格)
##### (1).df.iloc[ [列索引值], [行索引值] ]
##### (2).df.loc[ [列的名稱], [行的名稱] ]
這裡用df.iloc處理
![image](https://hackmd.io/_uploads/HyTbx69xle.png)

輸出Data Frame

---
#### 3.將nan改為各欄的平均值
##### (1).df.iloc[ [列索引值], [行索引值] ]
##### (2).df.loc[ [列的名稱], [行的名稱] ]
這裡用df.loc處理
![image](https://hackmd.io/_uploads/SkYMepclex.png)

輸出Data Frame
##### 看到小數點太多->四捨五入
![image](https://hackmd.io/_uploads/rJMXep9gex.png)


---
#### 參考資料 : 
###### [(aws.amazon)在 Windows 上安裝 Python、pip 和 EB CLI](https://docs.aws.amazon.com/zh_tw/elasticbeanstalk/latest/dg/eb-cli3-install-windows.html)
###### [(medium.com)[Python資料科學]pandas基礎介紹-進入資料科學的領域](https://medium.com/seaniap/pandas%E5%9F%BA%E7%A4%8E%E4%BB%8B%E7%B4%B9-%E9%80%B2%E5%85%A5%E8%B3%87%E6%96%99%E7%A7%91%E5%AD%B8%E7%9A%84%E9%A0%98%E5%9F%9F-be9894b3548)
###### [(shengyu7697.github.io)Python numpy 計算平均值 mean/average](https://shengyu7697.github.io/python-numpy-mean/)