title: Use NaN for values that can't be cast using astype
body: <p>I have a very large Pandas DataFrame that looks like this:</p>
  
  <pre><code>&gt;&gt;&gt; d = pd.DataFrame({"a": ["1", "U", "3.4"]})
  &gt;&gt;&gt; d
       a
  0    1
  1    U
  2  3.4
  </code></pre>
  
  <p>Currently the column is set as an <code>object</code>:</p>
  
  <pre><code>&gt;&gt;&gt; d.dtypes
  a    object
  dtype: object
  </code></pre>
  
  <p>I'd like to convert this column to float so that I can use <code>groupby()</code> and compute the mean. When I try it using <code>astype</code> I correctly get an error because of the string that can't be cast to float:</p>
  
  <pre><code>&gt;&gt;&gt; d.a.astype(float)
  ValueError: could not convert string to float: 'U'
  </code></pre>
  
  <p>What I'd like to do is to cast all the elements to float, and then replace the ones that can't be cast by NaNs.</p>
  
  <p>How can I do this?</p>
  
  <p>I tried setting <code>raise_on_error</code>, but it doesn't work, the <code>dtype</code> is still <code>object</code>.</p>
  
  <pre><code>&gt;&gt;&gt; d.a.astype(float, raise_on_error=False)
  0      1
  1      U
  2    3.4
  Name: a, dtype: object
  </code></pre>