title: replacing empty strings with NaN in Pandas
body: <p>I have a pandas dataframe (that was created by importing a csv file). I want to replace blank values with NaN. Some of these blank values are empty and some contain a (variable number) of spaces <code>''</code>, <code>' '</code>, <code>'    '</code>, etc.</p>
  
  <p>Using the suggestion from <a href="https://stackoverflow.com/questions/13445241/replacing-blank-values-white-space-with-nan-in-pandas">this thread</a> I have </p>
  
  <pre><code>df.replace(r'\s+', np.nan, regex=True, inplace = True)
  </code></pre>
  
  <p>which does replace all the strings that only contain spaces, but also replaces every string that has a space in it, which is not what I want.</p>
  
  <p>How do I replace only strings with <em>just</em> spaces and empty strings?</p>