【发布时间】:2021-01-01 11:49:04
【问题描述】:
我想将我的 Dataframe 中的列中的内容更改为“好”或“坏”。 该列填充有从 1 到 10 的数字。 1-5是坏的,6-10是好的。 为此,我想使用 cut 方法。
bins = (1, 5.5, 10)
rating = ['bad', 'good']
game['useropinion'] = pd.cut(rating, bins)
运行后的结果:
Cannot cast array data from dtype('float64') to dtype('<U32') according to the rule 'safe'
怎么了?我该如何解决?
【问题讨论】: