使用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 就好!