詹惠儿

2021-04-06   阅读量: 331

数据分析师

python报错:TypeError: ‘>’not supported between instances of str and int

扫码加入数据分析学习群

问:

python报错:TypeError: ‘>’not supported between instances of str and int


答:

这是因为原数据中的年龄字段是字符型,字符型的字段无法与数值型的‘50’进行比较,


将年龄字段的数据类型改为数值型即可:df.年龄 = df.年龄.astype('int')。



添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
108.9473 1 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子