title: Pandas converting column of strings and NaN (floats) to integers, keeping the NaN
body: <p>I have problems in converting a column which contains both numbers of 2 digits in string format (type: str) and NaN (type: float64). I want to obtain a new column made this way: NaN where there was NaN and integer numbers where there was a number of 2 digits in string format.
  As an example: I want to obtain column Yearbirth2 from column YearBirth1 like this:</p>
  
  <pre><code>YearBirth1  #numbers here are formatted as strings: type(YearBirth1[0])=str
          34  # and NaN are floats: type(YearBirth1[2])=float64.
          76
         Nan
          09
         Nan
          91
  
  YearBirth2  #numbers here are formatted as integers: type(YearBirth2[0])=int
          34  #NaN can remain floats as they were. 
          76
         Nan
           9
         Nan
          91
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>csv['YearBirth2'] = (csv['YearBirth1']).astype(int)
  </code></pre>
  
  <p>And as I expected i got this error:</p>
  
  <pre><code>ValueError: cannot convert float NaN to integer
  </code></pre>
  
  <p>So I tried this:</p>
  
  <pre><code>csv['YearBirth2'] = (csv['YearBirth1']!=NaN).astype(int)
  </code></pre>
  
  <p>And got this error:</p>
  
  <pre><code>NameError: name 'NaN' is not defined
  </code></pre>
  
  <p>Finally I have tried this:</p>
  
  <pre><code>csv['YearBirth2'] = (csv['YearBirth1']!='NaN').astype(int)
  </code></pre>
  
  <p>NO error, but when I checked the column YearBirth2, this was the result:</p>
  
  <pre><code>YearBirth2:
           1
           1
           1
           1
           1
           1
  </code></pre>
  
  <p>Very bad.. I think the idea is right but there is a problem to make Python able to understand what I mean for NaN.. Or maybe the method I tried is wrong.. </p>
  
  <p>I also used pd.to_numeric() method, but this way i obtain floats, not integers..</p>
  
  <p>Any help?!
  Thanks to everyone!</p>
  
  <p>P.S: csv is the name of my DataFrame;
  Sorry if I am not so clear, I am on improving with English language!</p>