pandas keep numerical part
<p>I have a set of data like: </p>

<pre><code>        0       1 
0  type 1  type 2
1  type 3  type 4
</code></pre>

<p>How can I transfer it to:</p>

<pre><code>   0  1
0  1  2
1  3  4
</code></pre>

<p>perfer using <code>apply</code>or <code>transform</code> function</p>

<pre><code>&gt;&gt;&gt; df.apply(lambda x: x.str.replace('type ','').astype(int))
   0  1
0  1  2
1  3  4
</code></pre>

<p>remove the <code>.astype(int)</code> if you don't need to convert to int</p>

python string pandas replace numeric