NOTE: pd.convert_objects has now been deprecated. You should use pd.Series.astype(float) or pd.to_numeric as described in other answers.

This is available in 0.11. Forces conversion (or set's to nan) This will work even when astype will fail; its also series by series so it won't convert say a complete string column

CopyIn [10]: df = DataFrame(dict(A = Series(['1.0','1']), B = Series(['1.0','foo'])))

In [11]: df
Out[11]: 
     A    B
0  1.0  1.0
1    1  foo

In [12]: df.dtypes
Out[12]: 
A    object
B    object
dtype: object

In [13]: df.convert_objects(convert_numeric=True)
Out[13]: 
   A   B
0  1   1
1  1 NaN

In [14]: df.convert_objects(convert_numeric=True).dtypes
Out[14]: 
A    float64
B    float64
dtype: object
Answer from Jeff on Stack Overflow
🌐
Medium
medium.com › @heyamit10 › secrets-of-pandas-astype-float-7d4fc8da8b7a
Secrets of pandas astype float. The biggest lie in data science? That… | by Hey Amit | Medium
April 12, 2025 - Yes, you can convert integers and strings that represent numbers to float. However, non-numeric strings will raise an error. ... If there are non-numeric values in the column, pandas raises a ValueError. You can use error handling techniques to manage this. ... Absolutely! You can apply astype(float) directly to any DataFrame column.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.astype.html
pandas.DataFrame.astype — pandas 3.0.3 documentation
The pandas object casted to the specified dtype. ... Convert argument to datetime. ... Convert argument to timedelta. ... Convert argument to a numeric type. ... Cast a numpy array to a specified type. ... Changed in version 2.0.0: Using astype to convert from timezone-naive dtype to timezone-aware dtype will raise an exception.
People also ask

What is the difference between astype() and to_numeric() in pandas?
astype() directly converts the data type but fails if invalid values exist. pd.to_numeric() is more flexible and can handle errors using parameters like errors='coerce'.
🌐
golinuxcloud.com
golinuxcloud.com › home › databases › convert pandas dataframe column to float (astype, to_numeric & practical examples)
Convert pandas DataFrame Column to Float (astype, to_numeric & ...
How do I convert all columns in a pandas DataFrame to float?
You can convert all columns using apply(). Example: df = df.apply(pd.to_numeric, errors='coerce') which converts columns to numeric values including float.
🌐
golinuxcloud.com
golinuxcloud.com › home › databases › convert pandas dataframe column to float (astype, to_numeric & practical examples)
Convert pandas DataFrame Column to Float (astype, to_numeric & ...
How do I convert a pandas column to float?
You can convert a pandas column to float using the astype() method. Example: df['column'] = df['column'].astype(float). This changes the column data type to float.
🌐
golinuxcloud.com
golinuxcloud.com › home › databases › convert pandas dataframe column to float (astype, to_numeric & practical examples)
Convert pandas DataFrame Column to Float (astype, to_numeric & ...
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › convert-pandas-dataframe-column-to-float
Convert Pandas Dataframe Column To Float - GeeksforGeeks
July 23, 2025 - Data types before conversion: C1 ... C1 C2 0 10.5 15.3 1 20.7 25.6 2 30.2 35.8 · We can convert the entire DataFrame using astype() function and passing float as datatype....
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas convert column to float in dataframe
Pandas Convert Column to Float in DataFrame - Spark By {Examples}
October 14, 2024 - By using pandas DataFrame.astype() and pandas.to_numeric() methods you can convert a column from string/int type to float. In this article, I will explain
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: How to use astype() to cast dtype of DataFrame | note.nkmk.me
August 9, 2023 - df_str = pd.read_csv('data/src/sample_header_index_dtype.csv', index_col=0, dtype=str) print(df_str) # a b c d # ONE 1 001 100 x # TWO 2 020 NaN y # THREE 3 300 300 z print(df_str.dtypes) # a object # b object # c object # d object # dtype: object print(df_str.applymap(type)) # a b c d # ONE <class 'str'> <class 'str'> <class 'str'> <class 'str'> # TWO <class 'str'> <class 'str'> <class 'float'> <class 'str'> # THREE <class 'str'> <class 'str'> <class 'str'> <class 'str'> ... If you read the file without specifying dtype and then cast it to str with astype(), NaN values are also converted to the string 'nan'.
🌐
GoLinuxCloud
golinuxcloud.com › home › databases › convert pandas dataframe column to float (astype, to_numeric & practical examples)
Convert pandas DataFrame Column to Float (astype, to_numeric & Practical Examples) | GoLinuxCloud
March 9, 2026 - This method explicitly casts the column data type to float. ... import pandas as pd df = pd.DataFrame({ "price": [10, 20, 30, 40] }) df["price"] = df["price"].astype(float) print(df.dtypes)
Find elsewhere
🌐
Medium
medium.com › @heyamit10 › understanding-pandas-astype-with-examples-f1b21ad17e69
Understanding pandas astype() with Examples | by Hey Amit | Medium
March 6, 2025 - The original numbers were floating points (like 1.1, 2.2). Using astype(int), we converted them to integers (1, 2), and yes—it truncates the decimal part without rounding.
🌐
Statology
statology.org › home › how to convert object to float in pandas (with examples)
How to Convert Object to Float in Pandas (With Examples)
May 11, 2022 - You can use one of the following methods to convert a column in a pandas DataFrame from object to float: Method 1: Use astype() df['column_name'] = df['column_name'].astype(float) Method 2: Use to_numeric() df['column_name'] = pd.to_numeric...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.3 documentation - PyData |
numpy.ndarray.astype · Cast a numpy array to a specified type. DataFrame.convert_dtypes · Convert dtypes. Examples · Take separate series and convert to numeric, coercing when told to · >>> s = pd.Series(["1.0", "2", -3]) >>> pd.to_numeric(s) 0 1.0 1 2.0 2 -3.0 dtype: float64 >>> pd.to_numeric(s, downcast="float") 0 1.0 1 2.0 2 -3.0 dtype: float32 >>> pd.to_numeric(s, downcast="signed") 0 1 1 2 2 -3 dtype: int8 >>> s = pd.Series(["apple", "1.0", "2", -3]) >>> pd.to_numeric(s, errors="coerce") 0 NaN 1 1.0 2 2.0 3 -3.0 dtype: float64 ·
🌐
Practical Business Python
pbpython.com › pandas_dtypes.html
Overview of Pandas Data Types - Practical Business Python
Customer Number float64 Customer Name object 2016 object 2017 object Percent Growth object Jan Units object Month int64 Day int64 Year int64 Active bool dtype: object · Whether you choose to use a lambda function, create a more standard python function or use another approach like np.where() , these approaches are very flexible and can be customized for your own unique data needs. Pandas has a middle ground between the blunt astype...
🌐
Skytowner
skytowner.com › explore › converting_column_type_to_float_in_pandas_dataframe
Converting column type to float in Pandas DataFrame
To convert the column type to float in Pandas DataFrame, either use the Series' astype() method, or use Pandas' to_numeric() method.
🌐
datagy
datagy.io › home › pandas tutorials › data analysis in pandas › converting pandas dataframe column from object to float
Converting Pandas DataFrame Column from Object to Float • datagy
May 12, 2023 - The easiest way to convert a Pandas DataFrame column’s data type from object (or string) to float is to use the astype method.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pandas-dataframe-astype
Pandas DataFrame.astype()-Python - GeeksforGeeks
June 26, 2025 - Explanation: astype() method is used with a dictionary to convert 'A' to integer and 'B' to float. Both columns are now in numeric form, suitable for calculations. Example 3: In this, we try to convert column 'A' to integer, but due to a non-numeric ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-floats-to-strings-in-pandas-dataframe
How to Convert Floats to Strings in Pandas DataFrame? - GeeksforGeeks
July 15, 2025 - # Import pandas library import pandas as pd # initialize list of lists data = [['Harvey.', 10.5, 45.25, 95.2], ['Carson', 15.2, 54.85, 50.8], ['juli', 14.9, 87.21, 60.4], ['Ricky', 20.3, 45.23, 99.5], ['Gregory', 21.1, 77.25, 90.9], ['Jessie', 16.4, 95.21, 10.85]] # Create the pandas DataFrame df = pd.DataFrame(data, columns = ['Name', 'Age', 'Marks', 'Accuracy'], index = ['a', 'b', 'c', 'd', 'e', 'f']) # lets find out the data type # of 'Age' and 'Accuracy' columns print (df.dtypes) ... Now, we change the data type of columns 'Accuracy' and 'Age' from 'float64' to 'object'. ... # Now Pass a dictionary to # astype() function which contains # two columns and hence convert them # from float to string type df = df.astype({"Age": 'str', "Accuracy": 'str'}) print() # lets find out the data # type after changing print(df.dtypes) # print dataframe.
🌐
Upgrad
upgrad.com › home › blog › data science › a comprehensive guide to pandas dataframe astype()
A Comprehensive Guide to Pandas DataFrame astype()
February 3, 2025 - Pandas astype() is used to cast a DataFrame column (or multiple columns) to a specified data type. It allows you to convert data types, such as changing integers to floats, strings to categorical types, or objects to datetime.
🌐
W3Schools
w3schools.com › python › pandas › ref_df_astype.asp
Pandas DataFrame astype() Method
You can cast the entire DataFrame to one specific data type, or you can use a Python Dictionary to specify a data type for each column, like this: { 'Duration': 'int64', 'Pulse' : 'float', 'Calories': 'int64' } ... The copy and errors parameters ...
🌐
Statology
statology.org › home › how to convert strings to float in pandas
How to Convert Strings to Float in Pandas
November 28, 2022 - You can use the following methods to convert a string to a float in pandas: ... #convert both "assists" and "rebounds" from strings to floats df[['assists', 'rebounds']] = df[['assists', 'rebounds']].astype(float)
🌐
w3resource
w3resource.com › python-exercises › pandas › pandas-convert-column-data-types-using-astype.php
Pandas - Convert column data types using astype()
In this exercise, we have converted the data types of columns in a DataFrame using the astype() method. ... import pandas as pd # Create a sample DataFrame with mixed types df = pd.DataFrame({ 'ID': ['1', '2', '3'], 'Price': ['10.5', '20.0', '30.5'] }) # Convert 'ID' to integer and 'Price' to float df['ID'] = df['ID'].astype(int) df['Price'] = df['Price'].astype(float) # Output the result print(df)