Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python convert number with a comma and decimal to a float

from locale import atof, setlocale, LC_NUMERIC
setlocale(LC_NUMERIC, '') # set to your default locale; for me this is
# 'English_Canada.1252'. Or you could explicitly specify a locale in which floats
# are formatted the way that you describe, if that's not how your locale works :)
atof('123,456') # 123456.0
# To demonstrate, let's explicitly try a locale in which the comma is a
# decimal point:
setlocale(LC_NUMERIC, 'French_Canada.1252')
atof('123,456') # 123.456
Comment

PREVIOUS NEXT
Code Example
Python :: number of columns with no missing values 
Python :: pandas subtract integer from column 
Python :: print last n rows of dataframe 
Python :: ordered char list python 
Python :: check if numpy arrays are equal 
Python :: pandas open text file 
Python :: connect to mysql database jupyter 
Python :: how to clean a mask cv2 in python 
Python :: django.db.utils.OperationalError: no such table: 
Python :: elon son name 
Python :: nlargest 
Python :: arabic in python 
Python :: leap year algorithm 
Python :: how to receive user input in python 
Python :: how to use colorama 
Python :: python armstrong number 
Python :: dataframe from arrays python 
Python :: pygame hide cursor 
Python :: python math cube root 
Python :: get csrf_token value in django template 
Python :: python how to copy a 2d array leaving out last column 
Python :: how to change the title of a tkinter widnow 
Python :: get cpu count in python 
Python :: cvtcoloer opencv 
Python :: matplotlib show percentage y axis 
Python :: flask console log 
Python :: download kaggle dataset in colab 
Python :: how to get what type of file in python 
Python :: py insert char at index 
Python :: perfect number program in python 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =