기초 튼튼/시행착오노트
[시행착오노트] Pandas에서 astype 사용시 Null값을 남기고 싶은 경우
JoeSung
2021. 3. 9. 14:45
이슈:
astype을 통해 int로 타입 변경시 아래 에러가 발생하며 null값은 변환이 안된다.
pandas.errors.IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer
해결:
-1로 변경 후 integer타입 변경 그리고 replace함수 활용하여 Null 후처리
참고 : stackoverflow.com/questions/21287624/convert-pandas-column-containing-nans-to-dtype-int
반응형