logo
Loading...

[np.percentile(app_train[~app_train['AMT_ANNUITY'].isnull()]['AMT_ANNUITY'], q = i) for i in five_num]程式問題 - Cupoy

範例quantile_5s = [np.percentile(app_train[~app_trai...

ml100-2,ml100-2-d07

[np.percentile(app_train[~app_train['AMT_ANNUITY'].isnull()]['AMT_ANNUITY'], q = i) for i in five_num]程式問題

2019/05/08 06:30 AM
機器學習新手論壇
李明俊
觀看數:0
回答數:1
收藏數:1
ml100-2
ml100-2-d07

範例

quantile_5s = [np.percentile(app_train[~app_train['AMT_ANNUITY'].isnull()]['AMT_ANNUITY'], q = i) for i in five_num]


改寫後

quantile_5s = [np.percentile(app_train['AMT_ANNUITY'], q = i) for i in five_num]

執行輸出為 [nan, nan, nan, nan, nan]


1. isnull()是用來判斷是否有缺少數值,單純執行

~app_train['AMT_ANNUITY'].isnull()

執行輸出皆為 True


2. 執行app_train['AMT_ANNUITY']app_train[~app_train['AMT_ANNUITY'].isnull()]['AMT_ANNUITY']

輸出結果都一樣,為何在做percentile動作時,改寫成前者會有問題?