If you're reading in from csv then you can use the thousands arg:

df.read_csv('foo.tsv', sep='\t', thousands=',')

This method is likely to be more efficient than performing the operation as a separate step.


You need to set the locale first:

In [ 9]: import locale

In [10]: from locale import atof

In [11]: locale.setlocale(locale.LC_NUMERIC, '')
Out[11]: 'en_GB.UTF-8'

In [12]: df.applymap(atof)
Out[12]:
      0        1
0  1200  4200.00
1  7000    -0.03
2     5     0.00
Answer from Andy Hayden on Stack Overflow
Discussions

python - Error Converting Pandas Dataframe to float with comma - Stack Overflow
so I got a Dataframe with at least 2-3 columns with numbers running from 1 to 3000, and the numbers have comma. I need to convert the numbers to float or int in all the relevant columns.this is an More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do I remove commas from data frame column - Pandas

Pandas has a built in replace method for "object" columns.

df["column"] = df["column"].str.replace(",","").astype(float)

Alternatively check out the pandas.to_numeric() function- I think this should work.

df["column"] = pd.to_numeric(df["column"])

You can also pass arguments for error handling with the pd.to_numeric() function. See the pandas documentation on it.

More on reddit.com
๐ŸŒ r/learnpython
2
2
December 29, 2016
python - How to Convert String Numeric with Comma into Float in Pandas Data Frame - Stack Overflow
I have a 600x30 sized .csv file all of whose data type is string but actually numeric, such as : '36,000' == 36000 I'd like to convert all of those into float most efficiently. How can I do this... More on stackoverflow.com
๐ŸŒ stackoverflow.com
March 8, 2018
Python pandas - can't convert string to float (I think b/c of multiple data types in column...)
Thanks u/Ihaveamodel3 for the solution, the original post was 95% of the way there. I added coerce & now it seems to work... dfteam1["cloff"] = pd.to_numeric(dfteam1["cloff"],errors='coerce') funny how coerce was needed. Thanks to u/omgu8mynewt for your reply as well. More on reddit.com
๐ŸŒ r/learnpython
5
2
July 17, 2022
๐ŸŒ
YouTube
youtube.com โ€บ watch
convert string number with comma to float python pandas - YouTube
Instantly Download or Run this code online at https://codegive.com Certainly! Below is a tutorial on how to convert a string number with commas to a float in...
Published ย  January 11, 2024
๐ŸŒ
Finxter
blog.finxter.com โ€บ python-string-to-float-with-comma-easy-conversion-guide
Python String to Float with Comma: Easy Conversion Guide โ€“ Be on the Right Side of Change
January 19, 2024 - It excels in handling and converting data in DataFrames, including the conversion of strings to floats. Imagine you have a file with comma-separated values and you want to convert these to a numeric data type: import pandas as pd # Example CSV data as a list for demonstration csv_data = ["number", "1,234.56", "7,890.12"] # Convert to DataFrame df = pd.DataFrame(csv_data, columns=['Original String']) # Convert the 'Original String' column to floats df['Float Representation'] = df['Original String'].replace(',', '', regex=True).astype(float) print(df)
๐ŸŒ
YouTube
youtube.com โ€บ watch
PYTHON : Convert number strings with commas in pandas DataFrame to float - YouTube
PYTHON : Convert number strings with commas in pandas DataFrame to float [ Gift : Animated Search Engine : https://www.hows.tech/p/recommended.html ] PYTHON...
Published ย  December 5, 2021
๐ŸŒ
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
๐ŸŒ
Python Guides
pythonguides.com โ€บ convert-string-to-float-in-python
Convert String With Comma To Float In Python: 3 Easy Methods
April 22, 2025 - Product Price Sales 0 Widget A 1234.56 10000 1 Widget B 2345.67 5000 2 Widget C 3456.78 2500 Data types: Product object Price float64 Sales int64 dtype: object ยท Pandas makes this process incredibly simple with the thousands parameter. This method has saved me countless hours when analyzing sales data from various US retailers. Check out Convert Hexadecimal String to Integer in Python ยท Letโ€™s look at a practical example of processing income data for different US states: import pandas as pd # Sample data: Median household income by state with comma formatting data = { 'State': ['California'
Find elsewhere
๐ŸŒ
Lifewithdata
lifewithdata.com โ€บ 2022 โ€บ 02 โ€บ 28 โ€บ how-to-convert-a-string-column-to-float-in-pandas
How to Convert a String Column to Float in Pandas
February 28, 2022 - Build a website. Sell your stuff. Write a blog. And so much more ยท This site is currently private. Log in to WordPress.com to request access
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ a โ€บ 43684468
python - Converting values with commas in a pandas dataframe to floats. - Stack Overflow
df['Date'] = pd.to_datetime(df['Date'], format='%m/%d/%Y') df['Close_y'] = df['Close_y'].str.replace(',','.').astype(float) replace looks for exact matches, what you're trying to do is replace any match in the string ... Sign up to request clarification or add additional context in comments. ... pandas.read_clipboard implements the same kwargs as pandas.read_table in which there are options for the thousands and parse_dates kwarg.s
๐ŸŒ
DataScientYst
datascientyst.com โ€บ convert-decimal-comma-to-decimal-point-pandas-dataframe
How to Convert Decimal Comma to Decimal Point in Pandas DataFrame
August 25, 2022 - Let's start with the optimal solution - convert decimal comma to decimal point while reading CSV file in Pandas. Method read_csv() has parameter three parameters that can help: ... This will ensure that the correct decimal symbol is used for the DataFrame. If the DataFrame contains values with comma then we can convert them by .str.replace(): df['humidity_eu'].str.replace(',', '.').astype(float)
๐ŸŒ
Kaggle
kaggle.com โ€บ getting-started โ€บ 58882
How to convert string into float or remove comma from ...
Checking your browser before accessing www.kaggle.com ยท Click here if you are not automatically redirected after 5 seconds
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-handle-the-pandas-valueerror-could-not-convert-string-to-float
How to Handle the pandas ValueError could not convert string to float | Saturn Cloud Blog
October 19, 2023 - We utilize the replace() function with a regular expression to remove the commas, making the strings convertible to floats. Finally, we convert the column to floats using the astype() function.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-convert-strings-to-floats-in-pandas-dataframe
How to Convert String to Float in Pandas DataFrame - GeeksforGeeks
January 18, 2024 - String values are not very useful in data analysis, but changing them to float will provide much more value in your data analysis project. In this tutorial, we have covered the DataFrame.astype() and pandas.to_numeric() functions to convert ...
๐ŸŒ
IncludeHelp
includehelp.com โ€บ python โ€บ pandas-convert-commas-decimal-separators-to-dots-within-a-dataframe.aspx
Python Pandas: Convert commas decimal separators to dots within a Dataframe
July 28, 2022 - # Importing Pandas package import pandas as pd # Creating a Dictionary d = { 'a': ['120,00', '42,00', '18,00', '23,00'], 'b': ['51,23', '18,45', '28,90', '133,00'] } # Creating a dataframe df = pd.DataFrame(d) # Display Original dataframe print("Created Dataframe:\n",df,"\n") # Replacing , with . df['a'] = df['a'].replace(',','.',regex=True) df['b'] = df['b'].replace(',','.',regex=True) # Converting the data type df['a'] = df['a'].astype(float) df['b'] = df['b'].astype(float) # Display modified DataFrame print("Modified DataFrame:\n",df)
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-convert-number-strings-with-commas-in-pandas-dataframe-to-float
Saturn Cloud | Saturn Cloud | The Control Plane for GPU Clouds
June 19, 2023 - Saturn Cloud is the white-labeled control plane for GPU clouds: multi-tenant isolation, day-2 support, and integrated billing, running in your cloud under your brand.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ convert-string-with-comma-to-float-in-python
Convert String with Comma To Float in Python - GeeksforGeeks
February 6, 2024 - In this article, we will explore five generally used methods for converting a string with a comma separator and dot to a float.