Sometimes, we want to convert Python Pandas column containing NaNs to dtype int, we call astype.
In this article, we’ll look at how to convert Python Pandas column containing NaNs to dtype int, we call astype
How to convert Python Pandas column containing NaNs to dtype int?
To convert Python Pandas column containing NaNs to dtype int, we call astype.
For instance, we write
df[col] = df[col].astype(int)
to call astype with int to convert values in column col to ints.
Conclusion
To convert Python Pandas column containing NaNs to dtype int, we call astype.