成功解决TypeError: data type ‘category‘ not understood

简介: 成功解决TypeError: data type ‘category‘ not understood


目录

解决问题

解决思路

解决方法


解决问题

TypeError: data type 'category' not understood

解决思路

类型错误:不理解数据类型“类别”

解决方法

在if判断的时候,除了内容相同之外,一定要观察两边的对象到底是不是类型也相同,比如我在进行以下判断的时候,内容相同,但是两边的类型却不相同,经常输出查看,左边的却是类型,所以当然,会报错!

需要将

1. if df[col].dtypes=='category'
2. 改为
3. if str(df[col].dtypes)=='category':


相关文章
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
Error: Element type is invalid: expected a string (for built-in components) or a class/function
2532 0
【已解决】Error: Element type is invalid: expected a string (for built-in components) or a class/function
|
5月前
|
iOS开发 MacOS
TypeError: Cannot read property ‘shop‘ of undefined
TypeError: Cannot read property ‘shop‘ of undefined
35 0
|
前端开发 JavaScript
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
1341 0
前端vue:解决Invalid prop: type check failed for prop “model“. Expected Object, got Array问题
|
12月前
|
人工智能 自然语言处理 语音技术
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
109 0
解决AttributeError: ‘model‘ object has no attribute ‘copy‘
原因是没有使用model.state_dict()进行模型保存,但是使用了model.load_state_dict()加载模型。这两者要配套使用。
404 0
AttributeError: ‘set‘ object has no attribute ‘items‘
出现这个问题,原因可能是定义的header有问题
164 0
|
Python
AttributeError: type object ‘Image‘ has no attribute ‘open‘
原因分析:Image调用顺序出错,因为第一行的from PIL import Image与第二行tkinter import *冲突,tkinter中也含有Image类,所以你使用的是tkinter.Image
233 0
|
TensorFlow 算法框架/工具
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘
269 0
解决TypeError: tf__update_state() got an unexpected keyword argument ‘sample_weight‘