title: python pandas - generic ways to deal with commas in string to float conversion with astype()
body: <p>is there a generic way to tell pandas to use a comma (&quot;,&quot;) as decimal separators for type conversion from string to float etc.?</p>
  <pre><code>import pandas as pd
  from datetime import datetime
  
  data = {
      &quot;col_str&quot;: [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;],
      &quot;col_int&quot;: [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;],
      &quot;col_float&quot;: [&quot;1,2&quot;, &quot;3,2342&quot;, &quot;97837,8277&quot;],
      &quot;col_float2&quot;: [&quot;13,2&quot;, &quot;3234,2342&quot;, &quot;263,8277&quot;],
      &quot;col_date&quot;: [datetime(2020, 8, 1, 0, 3, 4).isoformat(),
                   datetime(2020, 8, 2, 2, 4, 5).isoformat(),
                   datetime(2020, 8, 3, 6, 8, 4).isoformat()
                   ]
  }
  
  conversion_dict = {
      &quot;col_str&quot;: str,
      &quot;col_int&quot;: int,
      &quot;col_float&quot;: float,
      &quot;col_float2&quot;: float,
      &quot;col_date&quot;: &quot;datetime64&quot;
  }
  
  df = pd.DataFrame(data=data)
  
  print(df.dtypes)
  df = df.astype(conversion_dict, errors=&quot;ignore&quot;)
  print(df.dtypes)
  print(df)
  </code></pre>
  <p>The above example returns object-columns for &quot;col_float&quot; and &quot;col_float2&quot; or throws an error is errors is set to &quot;raise&quot;.</p>
  <p>I would like to use the astype()-method directly without manually replacing commas with dots.
  The datasource generally returns floats with commas as decimal separator because the locale is set to german.</p>
  <p>Is there a generic way to tell pandas as type that commas in floats - or any other numeric data type with decimals - are ok and should be converted automatically?</p>
  <p>PS: I can´t use read_csv where you can specify the separator directly, because it´s a database.</p>
  <p>Thanks in advance.</p>