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.

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 *