title: How to handle NaTs with pandas sqlalchemy and psycopg2
body: <p>I have a dataframe with NaTs like so that is giving me a <code>DataError: (psycopg2.DataError) invalid input syntax for type timestamp: "NaT"</code>: When I try inserting the values into a postgres db</p>
  
  <h3>The dataframe</h3>
  
  <pre><code>from sqlalchemy import MetaData
  from sqlalchemy.dialects.postgresql import insert
  import pandas as pd
  
  tst_df = pd.DataFrame({'colA':['a','b','c','a','z', 'q'],
                    'colB': pd.date_range(end=datetime.datetime.now() , periods=6),
                    'colC' : ['a1','b2','c3','a4','z5', 'q6']})
  tst_df.loc[5, 'colB'] = pd.NaT
  
  
  
  insrt_vals = tst_df.to_dict(orient='records')
  engine = sqlalchemy.create_engine("postgresql://user:password@localhost/postgres")
  connect = engine.connect()
  meta = MetaData(bind=engine)
  meta.reflect(bind=engine)
  table = meta.tables['tstbl']
  insrt_stmnt = insert(table).values(insrt_vals)
  
  do_nothing_stmt  = insrt_stmnt.on_conflict_do_nothing(index_elements=['colA','colB'])
  </code></pre>
  
  <h3>The code generating the error</h3>
  
  <pre><code>results = engine.execute(do_nothing_stmt)
  
  DataError: (psycopg2.DataError) invalid input syntax for type timestamp: "NaT"
  LINE 1: ...6-12-18T09:54:05.046965'::timestamp, 'z5'), ('q', 'NaT'::tim...
  </code></pre>
  
  <p>One possibility mentioned <a href="https://stackoverflow.com/questions/27384653/how-to-properly-insert-null-timestamps-to-postgres-using-pandas">here</a> is to replace the NaT's with None's but as the previous author said it seems a bit hackish.</p>
  
  <pre><code>sqlachemy  1.1.4
  pandas  0.19.1
  psycopg2 2.6.2 (dt dec pq3 ext lo64)
  </code></pre>