pandas报错:'<' not supported between instances of 'str' and 'int'


pandas报错:'<' not supported between instances of 'str' and 'int'

记录一个bug:

series原始数据如下:

image-20200504112232338

虽然我使用命令job_yearSeries=job_yearSeries.replace(to_replace=[r'\N'],value=int(-1))将那个\N转换为了-1,但是我没有改变series的数据类型。因为这个值的存在,该series的原始数据类型不是int而是str,所以调用job_yearSeries_boxed=pd.qcut(job_yearSeries,7)的时候会报错。解决方法就是改变数据类型:job_yearSeries=pd.to_numeric(job_yearSeries)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM