title: Convert column values to lower case only if they are string
body: <p>I'm having real trouble converting a column into lowercase. It's not as simple as just using:</p>
  
  <pre><code>df['my_col'] = df['my_col'].str.lower()
  </code></pre>
  
  <p>because I'm iterating over a lot of dataframes, and some of them (but not all) have both strings and integers in the column of interest. This causes the lower function, if applied like above, to throw an exception:</p>
  
  <pre><code>AttributeError: Can only use .str accessor with string values, which use np.object_ dtype in pandas
  </code></pre>
  
  <p>Rather than forcing the type to be a string, I'd like to assess whether values are strings and then - if they are - convert them to lowercase, and - if they are not strings - leave them as they are. I thought this would work:</p>
  
  <pre><code>df = df.apply(lambda x: x.lower() if(isinstance(x, str)) else x)
  </code></pre>
  
  <p>But it doesn't work... probably because I'm overlooking something obvious, but I can't see what it is!</p>
  
  <p>My data looks something like this:</p>
  
  <pre><code>                          OS    Count
  0          Microsoft Windows     3
  1                   Mac OS X     4
  2                      Linux     234
  3    Don't have a preference     0
  4  I prefer Windows and Unix     3
  5                       Unix     2
  6                        VMS     1
  7         DOS or ZX Spectrum     2
  </code></pre>