title: Python Pandas custom time format in Excel output
body: <p>I have used <code>pandas.groupby</code> to group a pandas DataFrame on two columns and calculate average and median times. My resulting dataset looks similar to this:</p>
  
  <pre><code>Size        Category        Average Time        Median Time
   1             A            0.002056385         0.000310995
                 B                                0.000310995
                 C            0.000310995
   10            A                                0.001852681
                 B            0.000310995
                 C            0.000310995
  </code></pre>
  
  <p>I would like to export this table to excel and format the Time Columns as a custom format in Excel like so (hh:mm:ss.000). In other words, I want to view the times as millisecond-level times. For example, 0.000310995 formatted in this fashion displays as 00:00:26.870 (26.870 seconds).</p>
  
  <p>Does anyone have any insight on how to accomplish this feat?</p>
  
  <p>UPDATE:</p>
  
  <p>I have gotten a bit closer by using <code>to_datetime(df['Average Time'], unit='d')</code>. My times are now formatted like <code>1970-01-01 00:02:57.638400</code> in the DataFrame. However, when using <code>to_excel</code> to export to Excel they are formatted as <code>1970-01-01 00:02:58</code> in the Excel output. At this point, I only need to drop the date portion and add millisecond precision to achieve my goal. Any thoughts?</p>
  
  <p>Thanks very much in advance for any help you can offer - </p>