云上快速入门,热门云上应用快速查找
丰富的线上&线下活动,深入探索云世界
做任务,得社区积分和周边
最真实的开发者用云体验
让每位学生受益于普惠算力
让创作激发创新
资深技术专家手把手带教
遇见技术追梦人
畅聊无限,分享你的技术见解
技术交流,直击现场
海量开发者使用工具、手册,免费下载
极速、全面、稳定、安全的开源镜像
开发手册、白皮书、案例集等实战精华
为开发者定制的Chrome浏览器插件
热门
目录
解决问题
解决思路
解决方法
TypeError: data type 'category' not understood
类型错误:不理解数据类型“类别”
在if判断的时候,除了内容相同之外,一定要观察两边的对象到底是不是类型也相同,比如我在进行以下判断的时候,内容相同,但是两边的类型却不相同,经常输出查看,左边的却是类型,所以当然,会报错!
需要将
1. if df[col].dtypes=='category' 2. 改为 3. if str(df[col].dtypes)=='category':