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
Discussions

What are possible causes of pandas converting an INT to Float?
If a datatype is not defined, pandas tries to infer the datatype. When pulling data from .csv or excel files, I think numeric values are almost always assumed to be floating point. My understanding is, when operating on two numeric values of different types, the output is the highest precision data type. So for example, when operating on a float and an integer, floats are higher precision and thus the output is a float and not an int. Likely what is happening in your code is you are importing from some other source that does not explicitly define the datatypes and they are being inferred as floating point values. This precision is cascaded through as the highest precision datatype. When you instantiate a dataframe, you can pass in a dtype keyword to indicate the datatypes of each column. Additionally, you can use the astype method to change it after the fact. For example: a = pd.DataFrame({'float': [1.,2.,3.,4.,5.], 'integer': [1,2,3,4,5]}) print(a) float integer 0 1.0 1 1 2.0 2 2 3.0 3 3 4.0 4 4 5.0 5 a['float'] = a['float'].astype(int) a['integer'] = a['integer'].astype(float) print(a) float integer 0 1 1.0 1 2 2.0 2 3 3.0 3 4 4.0 4 5 5.0 a = a.astype(int) print(a) float integer 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 a = a.astype(float) print(a) float integer 0 1.0 1.0 1 2.0 2.0 2 3.0 3.0 3 4.0 4.0 4 5.0 5.0 More on reddit.com
🌐 r/learnpython
4
1
March 30, 2021
python - Converting strings to floats in a DataFrame - Stack Overflow
How to covert a DataFrame column containing strings and NaN values to floats. And there is another column whose values are strings and floats; how to convert this entire column to floats. More on stackoverflow.com
🌐 stackoverflow.com
ELI5: Help me understand pandas display.float_format
aha its string formatting syntax, leaving this up for any latecomers https://python-reference.readthedocs.io/en/latest/docs/str/formatting.html More on reddit.com
🌐 r/eli5_programming
2
2
December 1, 2022
TypeError: 'float' object is not subscriptable
It could be a couple different things. Something is being accessed as a 'subscriptable' type, basically list or dict, but its actually a float. Often happens when you try to reference a dict key as the dict itself while iterating. You gotta use iteritems and iterkeys. Poast a snippet and we could probably help properly. More on reddit.com
🌐 r/pythontips
17
7
November 21, 2019
🌐
GeeksforGeeks
geeksforgeeks.org › python › formatting-integer-column-of-dataframe-in-pandas
Formatting float column of Dataframe in Pandas - GeeksforGeeks
October 3, 2025 - You can round float values to a fixed number of decimal places using pd.options.display.float_format. ... import pandas as pd data = {'Month': ['January', 'February', 'March', 'April'], 'Expense': [21525220.653, 31125840.875, 23135428.768, ...
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › user_guide › options.html
Options and settings — pandas 3.0.1 documentation
In [88]: import numpy as np In [89]: pd.set_eng_float_format(accuracy=3, use_eng_prefix=True) In [90]: s = pd.Series(np.random.randn(5), index=["a", "b", "c", "d", "e"]) In [91]: s / 1.0e3 Out[91]: a 303.638u b -721.084u c -622.696u d 648.250u e -1.945m dtype: float64 In [92]: s / 1.0e6 Out[92]: a 303.638n b -721.084n c -622.696n d 648.250n e -1.945u dtype: float64 · Use round() to specifically control rounding of an individual DataFrame ... Enabling this option will affect the performance for printing of DataFrame and Series (about 2 times slower). Use only when it is actually required.
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.to_numeric.html
pandas.to_numeric — pandas 3.0.1 documentation
Can be ‘integer’, ‘signed’, ‘unsigned’, or ‘float’. If not None, and if the data has been successfully cast to a numerical dtype (or if the data was numeric to begin with), downcast that resulting data to the smallest numerical dtype possible according to the following rules: ‘integer’ or ‘signed’: smallest signed int dtype (min.: np.int8)
🌐
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)
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-convert-strings-to-floats-in-pandas-dataframe
How to Convert String to Float in Pandas DataFrame - GeeksforGeeks
July 15, 2025 - DataFrame.astype() function enables ... string to float in DataFrame with examples: DataFrame.astype() method is used to cast a Pandas object to a specified datatype....
🌐
CopyProgramming
copyprogramming.com › howto › python-check-if-value-is-float-in-pandas
How to Check if a Value is Float in Pandas: Complete Guide 2026 - Python check if value is float in pandas
December 20, 2025 - Float64 is a pandas nullable dtype that uses pd.NA for missing values. Both are considered float types by is_float_dtype(). Float64 is recommended for new code. Q: Why does my object column with numbers return False for is_float_dtype()? A: Object dtype columns store mixed types as Python objects.
🌐
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
🌐
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.
🌐
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).
🌐
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. The method can be applied to a Pandas DataFrame column or to an entire DataFrame, making it very flexible.
🌐
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.
🌐
GoLinuxCloud
golinuxcloud.com › home › python pandas › convert pandas dataframe column to float (astype, to_numeric & practical examples)
Convert pandas DataFrame Column to Float (astype, to_numeric & Practical Examples) | GoLinuxCloud
January 24, 2022 - Learn how to convert pandas DataFrame columns to float using astype(), to_numeric(), and other practical methods. This tutorial explains how to convert string and object columns to float, handle invalid values, convert multiple columns, and safely process large datasets in pandas.
🌐
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?
🌐
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 ...