Convert decimal separator
<p>I'm loading a CSV where decimal value separator is <code>,</code> and I would like to replace it by <code>.</code> in order to proceed the analysis.</p>

<p>I see the <code>converters</code> option in <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow">pandas.read_csv</a> but to use it I need to provide a list of all column names (which I want to convert), which might not be a good idea since there are lots of columns.</p>

<p>What I have in mind is to look each cell in all columns and replace it. </p>

<pre><code>ii = len(list(df))-1
print ii
jj = len(df.ix[:,0])
print jj
for i in range(0, ii):
    for j in range(0, jj):
        df.ix[i,j] = df.ix[i,j].to_string().replace(',' , '.')
</code></pre>

<p>Is there a better approach?</p>

<p>You can use the <code>decimal</code> parameter of <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a>:</p>

<pre><code>df = pd.read_csv(file.csv, decimal=',')
</code></pre>

python python-2.7 pandas dataframe