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

背景: 使用Pandas的 idxmax / idxmin 求最大值/最小值的索引值, 报错
原因: 使用dtype查看数据类型, 必须是数值型 int/float 等
解决办法: 对该列使用 astype() 转换类型

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