pandas dropping of words in dataframe
<p>I have a sample dataframe that I wish to drop all words and keep the values. </p>

<pre><code>Column1    Column2    Column3    Column4                     Column5
5FQ        1.047      S$55.3     UG44.2 as of 02/Jun/2016    S$8.2 mm
</code></pre>

<p>Is it possible to drop words and keep all the numbers? IE: to get the desired results below:</p>

<pre><code>Column1    Column2    Column3    Column4    Column5
5          1.047      55.3       44.2       8.2
</code></pre>

<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.extract.html" rel="nofollow"><code>pd.Series.extract</code></a>:</p>

<pre><code>In [28]: for c in df:
    df[c] = df[c].str.extract('(\d+\.?\d*)', expand=False)
   ....:     

In [29]: df
Out[29]: 
  Column1 Column2 Column3 Column4 Column5
0       5   1.047    55.3    44.2     8.2
</code></pre>

<p>Note that this is a bit brittle, as in <code>Column4</code> it works because the date appeared after the quantity. Your question doesn't specify anything more precise, though.</p>

python regex dataframe