KnowledgeBoat Logo
|

Informatics Practices

Why does Python change the datatype of a column as soon as it stores an empty value (NaN) even though it has all other values stored as integer ?

Python Pandas

3 Likes

Answer

When a column in a pandas DataFrame contains a mixture of integers and missing values (NaNs), the data type is automatically changed to a floating-point type to accommodate these missing values because in Python integer types cannot store NaN values.

Answered By

1 Like


Related Questions