logo
Loading...

can only convert an array of size 1 to a Python scalar - Cupoy

can only convert an array of size 1 to a Python sc...

ml100-2,語法,ml100-2-d08

can only convert an array of size 1 to a Python scalar

2019/04/24 下午 07:10
機器學習共學討論版
黃稚翔
觀看數:10
回答數:1
收藏數:0
ml100-2
語法
ml100-2-d08

can only convert an array of size 1 to a Python scalar


如圖所示,執行時會出現以上的錯誤

(未修改任何程式)

回答列表

  • 2019/04/24 下午 11:59
    張維元 (WeiYuan)
    贊同數:2
    不贊同數:0
    留言數:1

    這題應該是程式碼有錯誤:


    app_train.loc[0:10000, ['NAME_CONTRACT_TYPE', 'AMT_INCOME_TOTAL', 'AMT_CREDIT', 'AMT_ANNUITY']].groupby(['NAME_CONTRACT_TYPE']).apply(lambda x: x / x.mean() )


    改成這樣試試看:


    app_train.loc[0:10000, ['NAME_CONTRACT_TYPE', 'AMT_INCOME_TOTAL', 'AMT_CREDIT', 'AMT_ANNUITY']].groupby(['NAME_CONTRACT_TYPE'])[['AMT_INCOME_TOTAL', 'AMT_CREDIT', 'AMT_ANNUITY']].apply(lambda x: x / x.mean() )