logo
Loading...

使用value_counts出現IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match - Cupoy

loc_a = app_train['OBS_60_CNT_SOCIAL_CIRCLE'].valu...

ml100-3,ml100-3-d09

使用value_counts出現IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match

2019/09/11 上午 10:39
機器學習共學討論版
嚴詩豪
觀看數:94
回答數:2
收藏數:0
ml100-3
ml100-3-d09

loc_a = app_train['OBS_60_CNT_SOCIAL_CIRCLE'].value_counts() < 20

loc_b = 'OBS_60_CNT_SOCIAL_CIRCLE'


app_train.loc[loc_a,loc_b].hist()

plt.show()


我是這樣寫loc_a = app_train['OBS_60_CNT_SOCIAL_CIRCLE'].value_counts() < 20
loc_b = 'OBS_60_CNT_SOCIAL_CIRCLE'

app_train.loc[loc_a,loc_b].hist()
plt.show()

我是這樣寫,然後他跳錯誤:

IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match


請問是哪裡出錯?

回答列表

  • 2019/09/11 上午 11:11
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:1

    嗨,你的 loc_a = app_train['OBS_60_CNT_SOCIAL_CIRCLE'].value_counts() < 20 為什麼要 value_counts?

  • 2019/09/12 下午 04:57
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    選擇 OBS_60_CNT_SOCIAL_CIRCLE 小於 20 的資料點繪製,不是value_counts()小於 20。所以這題的 loc_a = app_train['OBS_60_CNT_SOCIAL_CIRCLE'] < 20 就好!