This is conciser:

# select the float columns
df_num = df.select_dtypes(include=[np.float])
# select non-numeric columns
df_num = df.select_dtypes(exclude=[np.number])
Answer from RNA on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.types.is_float_dtype.html
pandas.api.types.is_float_dtype — pandas 3.0.1 documentation
Whether or not the array or dtype is of a float dtype. ... Check whether the provided array or dtype is of a numeric dtype. ... Check whether the provided array or dtype is of an integer dtype. ... Check whether an array-like or dtype is of the object dtype. ... >>> from pandas.api.types import is_float_dtype >>> is_float_dtype(str) False >>> is_float_dtype(int) False >>> is_float_dtype(float) True >>> is_float_dtype(np.array(["a", "b"])) False >>> is_float_dtype(pd.Series([1, 2])) False >>> is_float_dtype(pd.Index([1, 2.0])) True
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.types.is_float.html
pandas.api.types.is_float — pandas 3.0.1 documentation
pandas.api.types.is_float(obj)# Return True if given object is float. This method checks whether the passed object is a float type. It returns True if the object is a float, and False otherwise. Parameters: objobject · The object to check for float type. Returns: bool ·
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Index.is_floating.html
pandas.Index.is_floating — pandas 2.3.3 documentation
Check if the Index is a floating type. Deprecated since version 2.0.0: Use pandas.api.types.is_float_dtype instead
🌐
Reddit
reddit.com › r/learnpython › what are possible causes of pandas converting an int to float?
r/learnpython on Reddit: What are possible causes of pandas converting an INT to Float?
March 30, 2021 -

I don't use float at all in my program and randomly I'm getting an (easy to fix) bug that an input requires Int and float was provided. Here is some recent code, but this isnt the first time something like this happened. I'm looking for a general reasoning rather than this particular reasoning.

        x=df.loc[((df['FROM2'] > 599) & (df['FROM2'] < 700) & (df['y']==True))]
        z=pd.concat([z, x])

then later in the code...

    a= pd.merge(a, z, how = 'outer', indicator = True)
    a= a.loc[a['_merge'] == 'left_only'].copy()
    a.drop(columns = '_merge', inplace = True)
🌐
Medium
mike-diaz006.medium.com › what-i-learned-at-work-this-week-pandas-asserts-floats-63fe9a57500e
What I Learned at Work this Week: pandas Asserts Floats | by Mike Diaz | Medium
August 14, 2022 - pandas tries to maintain the data types it receives when writing the CSV. purchaser_id is an int, so it writes an int. price is a float, so we maintain that as well. But in my experience, it’s safest to standardize the data in your CSV so that it isn’t altered when being read by different programs.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.1 documentation - PyData |
‘float’: smallest float dtype (min.: np.float32) As this behaviour is separate from the core conversion to numeric values, any errors raised during the downcasting will be surfaced regardless of the value of the ‘errors’ input.
Find elsewhere
🌐
Practical Business Python
pbpython.com › pandas_dtypes.html
Overview of Pandas Data Types - Practical Business Python
In this specific case, we could convert the values to integers as well but I’m choosing to use floating point in this case. I also suspect that someone will recommend that we use a Decimal type for currency. This is not a native data type in pandas so I am purposely sticking with the float approach.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › convert-pandas-dataframe-column-to-float
Convert Pandas Dataframe Column To Float - GeeksforGeeks
July 23, 2025 - As you observe the output the data type of the string column is changed from object to float after using to_numeric() function. We can handle Non-convertible values, Missing values, and NaN values by using errors='coerce' parameter in pandas.to_numeric() function, errors='coerce' parameter instructs Pandas to replace non-convertible values with NaN (Not a Number).
🌐
Luasoftware
code.luasoftware.com › tutorials › pandas › pandas-check-column-is-float-and-convert
Pandas Check Column Is Float and Convert If Not
import pandas as pd items = [ {'name': 'Desmond', 'score': 1.5}, {'name': 'Jack', 'score': '0.369'}, {'name': 'Elon', 'score': 5}]df = pd.DataFrame(items) for index, row in df.iterrows(): print(row['name'], type(row['score'])) Desmond <class 'float'> Jack <class 'str'> Elon <class 'int'>
🌐
Saturn Cloud
saturncloud.io › blog › how-to-convert-a-column-in-pandas-dataframe-from-string-to-float
How to Convert a Column in Pandas DataFrame from String to Float | Saturn Cloud Blog
October 27, 2023 - Converting a column in a pandas DataFrame from a string to a float is a simple task that can be accomplished using the astype() method. In this blog post, we covered the steps required to convert a column from a string to a float.
🌐
Pandas
pandas.pydata.org › docs › dev › user_guide › integer_na.html
Nullable integer data type — pandas documentation - PyData |
In Working with missing data, we saw that pandas primarily uses NaN to represent missing data. Because NaN is a float, this forces an array of integers with any missing values to become floating point. In some cases, this may not matter much. But if your integer column is, say, an identifier, ...
🌐
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 - 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. What happens to non-numeric values when converting? Non-numeric values will cause a conversion error. You can use preprocessing steps to handle these before attempting to convert. Is there a performance difference in converting types?
🌐
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 how to convert one or multiple string columns to float type using examples. ... Use pd.to_numeric() to convert a column to numeric type. Use astype(float) for straightforward conversion if data is clean.
🌐
Medium
medium.com › @anala007 › float-display-in-pandas-no-more-scientific-notation-80e3dd28eabe
Float Display in Pandas: No More Scientific Notation | by Arun | Medium
May 12, 2023 - By default, these float values can be represented in scientific notation, like 1.2345e+04. While this is a compact and precise way to display large numbers, it might not always be the ...
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.api.types.is_float.html
pandas.api.types.is_float — pandas 2.3.2 documentation
pandas.api.types.is_float(obj)# Return True if given object is float. Returns: bool · Examples · >>> pd.api.types.is_float(1.0) True · >>> pd.api.types.is_float(1) False · On this page ·
🌐
Pandas
pandas.pydata.org › docs › dev › reference › api › pandas.api.types.is_float_dtype.html
pandas.api.types.is_float_dtype — pandas 3.0.0rc0+71.g476e987ac1 documentation
Whether or not the array or dtype is of a float dtype. ... Check whether the provided array or dtype is of a numeric dtype. ... Check whether the provided array or dtype is of an integer dtype. ... Check whether an array-like or dtype is of the object dtype. ... >>> from pandas.api.types import is_float_dtype >>> is_float_dtype(str) False >>> is_float_dtype(int) False >>> is_float_dtype(float) True >>> is_float_dtype(np.array(["a", "b"])) False >>> is_float_dtype(pd.Series([1, 2])) False >>> is_float_dtype(pd.Index([1, 2.0])) True
🌐
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 - We can see that the Price column’s data type is actually an object. Let’s now dive into how we can convert the column to a floating point value. To convert a Pandas column’s data type from object to float you can use the to_numeric function.