title: How to handle NaNs in pandas dataframe integer column to postgresql database
body: <p>I have a pandas dataframe with a "year" column. However some rows have a np.NaN value due to an outer merge. The data type of the column in pandas is therefore converted to float64 instead of integer (integer cannot store NaNs?). Next, I want to store the dataframe on a postGreSQL database. For this I use:</p>
  
  <pre><code>df.to_sql()
  </code></pre>
  
  <p>Everything works fine but my postGreSQL column is now type "double precision" and the np.NaN values are now [null]. This all makes sense since the input column type was float64 and not integer type.</p>
  
  <p>I was wondering if there is a way to store the results in an integer type column with [nans]. </p>
  
  <p>Example <a href="https://nbviewer.jupyter.org/gist/rutgerhofste/fd0c5e30b9e66693c4ea50564b342c4f" rel="nofollow noreferrer">Notebook</a></p>
  
  <p>Result of Ami's answer:</p>
  
  <p><a href="https://i.stack.imgur.com/Zlc58.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zlc58.png" alt="enter image description here"></a></p>