Format Pandas DF Header in Outlook Mail

Viewed 197

Is there a way to highlight the background of the cells just of the column headers when sending the dataframes in an Outlook email?

Here is my code creating one of the dataframes, called product_splits by using a groupby query on another DF.

product_splits = dma_fees.groupby(['TRADEABLE_INSTR_NAME','SIG_CURRENCY_CODE']).sum()
product_splits = product_splits.drop('NUMBER_OF_LOTS',axis=1)
product_splits = product_splits.sort_values(by=['DMA_FEE_SUBTOTAL'],ascending=False)
product_splits = product_splits.round({'DMA_FEE_SUBTOTAL': 0}).astype(int)
product_splits = product_splits.reset_index()

Here is my code creating the email.

import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'patrick.oneill@example.com'
mail.Subject = 'Example mail format for monthly Eurex DMA fee stats'
#mail.Body = "Hi,\n\nThe total Eurex DMA fees for the previous month were " + str(total_fees) + "\n"
mail.HTMLBody = """\
    <html>
      <head></head>
      <body>
      Hi All,<br>
      <br>
      The total Eurex DMA fees for the previous month per currency were:<br>
      <br>
      {3}
        <p><br>
           Fees broken down by product:<br>
           {0}
           <br>Fees broken down by trader:<br>
           {1}
           <br>Fees broken down by broker across Barclays & Goldmans:<br>
           {2}
           <br>Number of lots traded by broker across Barclays & Goldmans:<br>
           {4}


           Regards, <br>
           Patrick
        </p>
      </body>
    </html>

    """.format(product_splits.to_html(), trader_splits.to_html(), broker_splits.to_html(), total_fees.to_html(), count_contracts.to_html())

And here is a picture of how the dataframe currently looks in the email. Can I shade the background of the column headers somehow?

enter image description here

0 Answers
Related