title: Writing pandas DataFrame to Excel with different formats for different columns
body: <p>I am trying to write a pandas <code>DataFrame</code> to an <code>.xlsx</code> file where different numerical columns would have different formats. For example, some would show only two decimal places, some would show none, some would be formatted as percents with a "%" symbol, etc. </p>
  
  <p>I noticed that <code>DataFrame.to_html()</code> has a <code>formatters</code> parameter that allows one to do just that, mapping different formats to different columns.  However, there is no similar parameter on the <code>DataFrame.to_excel()</code> method. The most we have is a <code>float_format</code> that is global to all numbers.</p>
  
  <p>I have read many SO posts that are at least partly related to my question, for example: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/24493918/pandas-set-cell-format-in-excel-writer/24496905#24496905">Use the older <code>openpyxl</code> engine to apply formats one cell at a time</a>. This is the approach with which I've had the most success. But it means writing loops to apply formats cell-by-cell, remembering offsets, etc. </li>
  <li><a href="https://stackoverflow.com/questions/18115741/writing-percentages-in-excel-using-pandas">Render percentages by changing the table data itself into strings</a>. Going the route of altering the actual data inspired me to try dealing with decimal place formatting by calling <code>round()</code> on each column before writing to Excel - this works too, but I'd like to avoid altering the data.</li>
  <li>Assorted others, mostly about date formats</li>
  </ul>
  
  <p>Are there other more convenient Excel-related functions/properties in the pandas API that can help here, or something similar on <code>openpyxl</code>, or perhaps some way to specify output format metadata directly onto each column in the <code>DataFrame</code> that would then be interpreted downstream by different outputters?</p>