TypeError: reduction operation 'argmax' not allowed for this dtype

背景: 使用Pandas的 idxmax / idxmin 求最大值/最小值的索引值, 報錯
原因: 使用dtype查看數據類型, 必須是數值型 int/float 等
解決辦法: 對該列使用 astype() 轉換類型

df['col_1'] = df['col_1'].astype(int)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章