title: How to fill null values with appropriate values based on the datatype of the columns in pandas?
body: <p>I am reading a <code>csv</code> in <code>pandas</code>. Now I need to fill the empty values and dump it to a table. So this is what I do.</p>
  
  <pre><code>import pandas as pd
  from sqlalchemy import create_engine
  
  df = pd.read_csv(file_path)
  df.fillna('', inplace=True)
  engine = create_engine('postgresql://username:******@localhost:****/database')
  df.to_sql("my_table", engine)
  </code></pre>
  
  <p>Now the problem is for the columns that have <code>integer</code> values along with few missing values, <code>pandas</code> fills empty <code>string</code> for those missing values. So when dumping it to a table, <code>pandas</code> classifies the column type as a <code>string</code> and dumps it to a table. So this column gets <code>text</code> as datatype (in case of <code>postgres</code>) as opposed to not doing anything to fill the missing values and the column being correctly classified as an <code>integer</code> or <code>double precision</code> (in case of <code>postgres</code>) which is a correct behaviour. </p>
  
  <p>However this is not a problem for columns that have <code>string</code> values along with missing values since those missing values would be assigned an empty <code>string</code> anyway and won't affect the column type.</p>
  
  <p>Now what I want is a way to fill empty values with <code>0</code> for those columns that have integer or float values and <code>''</code> (empty string) for those columns that have <code>string</code> values. How do I do it in pandas?</p>
  
  <p><strong>Note:</strong> Some columns can also be <code>datetime</code> for which I don't plan to fill it with anything as of now.</p>