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>

<p>Yoou can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html" rel="nofollow"><code>DataFrame.replace</code></a>:</p>

<pre><code>print (df.replace({'type ': ''}, regex=True))
   0  1
0  1  2
1  3  4
</code></pre>

python string pandas replace numeric