title: How to format IPython html display of Pandas dataframe?
body: <p>How can I format IPython html display of pandas dataframes so that</p>
  
  <ol>
  <li>numbers are right justified</li>
  <li>numbers have commas as thousands separator</li>
  <li>large floats have no decimal places</li>
  </ol>
  
  <p>I understand that <code>numpy</code> has the facility of <code>set_printoptions</code> where I can do:</p>
  
  <pre><code>int_frmt:lambda x : '{:,}'.format(x)
  np.set_printoptions(formatter={'int_kind':int_frmt})
  </code></pre>
  
  <p>and similarly for other data types. </p>
  
  <p>But IPython does not pick up these formatting options when displaying dataframes in html. I still need to have</p>
  
  <pre><code>pd.set_option('display.notebook_repr_html', True)
  </code></pre>
  
  <p>but with 1, 2, 3 as in above.</p>
  
  <p><strong>Edit:</strong> Below is my solution for 2 &amp; 3 ( not sure this is the best way ), but I still need to figure out how to make number columns right justified.</p>
  
  <pre><code>from IPython.display import HTML
  int_frmt = lambda x: '{:,}'.format(x)
  float_frmt = lambda x: '{:,.0f}'.format(x) if x &gt; 1e3 else '{:,.2f}'.format(x)
  frmt_map = {np.dtype('int64'):int_frmt, np.dtype('float64'):float_frmt}
  frmt = {col:frmt_map[df.dtypes[col]] for col in df.columns if df.dtypes[col] in frmt_map.keys()}
  HTML(df.to_html(formatters=frmt))
  </code></pre>