convert decimal mark
You may do it the locale-aware way:
import locale
# Set to users preferred locale:
locale.setlocale(locale.LC_ALL, '')
# Or a specific locale:
locale.setlocale(locale.LC_NUMERIC, "en_DK.UTF-8")
print locale.atof("3,14")
Read this section before using this method.
float("2,5".replace(',', '.'))
will do in most cases
If value
is a large number and .
has been used for thousands, you can:
Replace all commas for points: value.replace(",", ".")
Remove all but the last point: value.replace(".", "", value.count(".") -1)
Pandas supports this out of the box:
df = pd.read_csv(r'data.csv', decimal=',')
See http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html