태그

2022년 9월 1일 목요일

Pandas - NaN is a float

 

현상

When I concate or merge, some columns are forced to change to Float64


원인

In Working with missing data, we saw that pandas primarily uses NaN to represent missing data. Because NaN is a float, this forces an array of integers with any missing values to become floating point. In some cases, this may not matter much. But if your integer column is, say, an identifier, casting to float can be problematic. Some integers cannot even be represented as floating point numbers.


해결

astype('Int64') 임의변경