Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. 如何將所有欄位顯示出來?
- pd.set_option('display.max_columns', None)
- 2. 如何移除欄位?
- 單欄位
- train = train.drop(['欄位'], axis=1)
- 多欄位
- train = train.drop(['欄位1','欄位2'], axis=1)
- 3. 如何查看欄位的型別?
- train.dtypes
- 4. 如何轉換欄位型別?
- 以 int64 轉換為 str
- feature['欄位1'] = feature['欄位1'].apply(str)
- 或
- feature['欄位1'] = featuer['欄位1'].astype(str)
- 5. 如何觀察特徵之間的關聯性?
- feature.corr() #型別需為int
- 6. 如何畫散佈圖?
- import matplotlib.pyplot as plt #匯入相關套件
- plt.scatter(x, y)
- plt.show() #顯示圖
- 7. 如何將同資料型態選取出來?
- int_type = train.select_dtypes(include=['int32','int64','float64'])
- cat_type = train.select_dtypes(include=['object'])
- 8. 如何將統計出空值的數量排序?
- train.isnull().sum().sort_values(ascending=False)
- 9. 如何取出欄位?
- y = train.pop('欄位')
- 10. 如何計算出現次數?
- y['欄位'].value_counts()
- 11. 如何將欄位設定為索引?
- #會將第一列設定為索引
- test = pd.read_csv('Desktop/house-prices-advanced-regression-techniques/test.csv', index_col = 0)
- 12.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement