‘DataFrame‘ object has no attribute ‘cut‘
程序员文章站
2022-03-20 18:05:23
...
‘DataFrame’ object has no attribute ‘cut’
**问题:**使用pandas时处理数据运用cut()函数处理数据时报错’DataFrame’ object has no attribute ‘cut’。
**原因:**函数调用错误。
**解决:**通过pandas库调用cut(),不能直接对数据使用。
bins = [df.score.min()-1,400,450,df.score.max()+1]
lable = ['一般','较好','优秀']
df['类别'] = pd.cut(df.score,bins,right = False,labels = lable)
print(df)
推荐阅读
-
AttributeError: 'module' object has no attribute 'main'
-
解决Keras报错AttributeError: 'NoneType' object has no attribute 'inbound_nodes'
-
解决'DataFrame' object has no attribute 'sort'
-
‘MyObject‘ object has no attribute ‘***‘
-
AttributeError: ‘NoneType‘ object has no attribute ‘origin‘解决办法
-
AttributeError: ‘set‘ object has no attribute ‘append‘解决办法
-
解决:'Tensor' object has no attribute 'numpy'
-
str‘ object has no attribute ‘decode‘解决办法
-
'module' object has no attribute
-
AttributeError: 'GridSearchCV' object has no attribute 'grid_scores_'