Categories
Python Answers

How to convert Python Pandas column containing NaNs to dtype int?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *