使用dtype_select = ['float64','int64']app_train.dtypes.isin(dtype_select),執行的結果全為False?
2019/05/01 下午 05:24
機器學習共學討論版
許丕敏
觀看數:3
回答數:1
收藏數:0
ml100-2
dtypes.isin
語法
ml100-2-d06
dtype_select = ['float64','int64']
app_train.dtypes.isin(dtype_select)
寫法是定義數值的資料的list然後用 isin to get True/False list,
但執行的結果全為False, 不是很了解為何, 請幫忙解惑
回答列表
-
2019/05/01 下午 10:29張維元 (WeiYuan)贊同數:1不贊同數:0留言數:2
dtypes.isin 當中要放的是是 dtype 的型態,而不是字串,所以必須這麼寫會比較好:
```
app_train.dtypes.isin([np.dtype('int64'), np.dtype('float64')])
```
也可以改用對 df 直接做 select_dtypes:
```
app_train.select_dtypes(include=['float64', 'int64'])
```