Categories
Python Answers

How to change column type in Python Pandas?

Spread the love

To change column type in Python Pandas, we can use the to_numeric function.

For instance, we write

s = pd.Series(["8", 6, "7.5", 3, "0.9"])
pd.to_numeric(s)

to call to_numeric on the s series to convert all entries in the series from strings to numbers.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.