title: Pandas convert strings to numeric if possible; else keep string values
body: <p>I have a Pandas Dataframe which has columns which look something like this:</p>
  
  <pre><code>df:
  
  Column0   Column1     Column2
  'MSC'       '1'        'R2'
  'MIS'       'Tuesday'  '22'
  '13'        'Finance'  'Monday'
  </code></pre>
  
  <p>So overall, in these columns are actual strings but also numeric values (integers) which are in string format.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/15891038/change-data-type-of-columns-in-pandas">this</a> nice post about the <code>pd.to_numeric</code> and <code>astype()</code> methods, but I can't see if or how I could use them in my case.</p>
  
  <p>Using:</p>
  
  <pre><code>pd.to_numeric(df, errors = 'ignore')
  </code></pre>
  
  <p>just results in skiping the whole columns. Instead of skipping the whole columns, I only want to skip the strings in those columns which can't be converted, move on to the next entry and try to convert the next string.</p>
  
  <p>So in the end, my dataframe would look like this:</p>
  
  <pre><code>df:
  
  Column0   Column1     Column2
  'MSC'       1          'R2'
  'MIS'      'Tuesday'    22
   13        'Finance'  'Monday'
  </code></pre>
  
  <p>Is there maybe an efficient way to loop over these columns and achieve that?</p>
  
  <p>Best regards,
  Jan</p>
  
  <p><strong>EDIT:</strong>
  Thanks for all your suggestions! Since I am still a python beginner, @coldspeed and @sacul 's answers are easier to understand for me so I will go with one of them!</p>