title: pandas: convert multiple columns to string
body: <p>I have some columns <code>['a', 'b', 'c', etc.]</code> (<code>a</code> and <code>c</code> are <code>float64</code> while <code>b</code> is <code>object</code>)</p>
  
  <p>I would like to convert all columns to string and preserve <code>nan</code>s.</p>
  
  <p>Tried using <code>df[['a', 'b', 'c']] == df[['a', 'b', 'c']].astype(str)</code> but that left blanks for the <code>float64</code> columns.</p>
  
  <p>Currently I am going through one by one with the following:</p>
  
  <pre><code>df['a'] = df['a'].apply(str)
  df['a'] = df['a'].replace('nan', np.nan)
  </code></pre>
  
  <p>Is the best way to use <code>.astype(str)</code> and then replace <code>''</code> with <code>np.nan</code>? <em>Side question: is there a difference between <code>.astype(str)</code> and <code>.apply(str)</code>?</em></p>
  
  <p><strong>Sample Input:</strong> (dtypes: a=float64, b=object, c=float64)</p>
  
  <pre><code>a, b, c, etc.
  23, 'a42', 142, etc.
  51, '3', 12, etc.
  NaN, NaN, NaN, etc.
  24, 'a1', NaN, etc.
  </code></pre>
  
  <p><strong>Desired output:</strong> (dtypes: a=object, b=object, c=object)</p>
  
  <pre><code>a, b, c, etc.
  '23', 'a42', '142', etc.
  '51', 'a3', '12', etc.
  NaN, NaN, NaN, etc.
  '24', 'a1', NaN, etc.
  </code></pre>