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