How do I apply a regex substitution in a string column
<p>I have a data frame with a column like below</p>

<pre><code>Years in current job
&lt; 1 year
10+ years
9 years
1 year
</code></pre>

<p>I want to use regex or any other technique in python to get the result as</p>

<pre><code>Years in current job
1
10
9
1
</code></pre>

<p>I got something like this but, i guess it can be done in a better way using regex</p>

<pre><code>frame["Years in current job"] = frame["Years in current job"].str.replace(" ","")
frame["Years in current job"] = frame["Years in current job"].str.replace("&lt;","")
frame["Years in current job"] = frame["Years in current job"].str.replace("year","")
frame["Years in current job"] = frame["Years in current job"].str.replace("years","")
</code></pre>

<pre><code>df['Years in current job'] = df['Years in current job'].str.replace('\D+', '').astype('int')
</code></pre>

<p>Regex <code>\D+</code> search non-digits (and replace with empty string)</p>

<hr>

<p>I found this on SO: <a href="http://stackoverflow.com/a/22591024/1832058">http://stackoverflow.com/a/22591024/1832058</a></p>

python regex pandas