Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29934

Send pandas dataframe data as html e-mail

$
0
0

I want to send a pandas dataframe data as an HTML e-mail. Based on this post I could create an html with the dataframe. Code

import pandas as pd
import numpy as np

HEADER = '''<html>
    <head>

    </head>
    <body>
'''
FOOTER = '''</body>
</html>
'''

df = pd.DataFrame([[1.1, 1.1, 1.1, 2.6, 2.5, 3.4,2.6,2.6,3.4,3.4,2.6,1.1,1.1,3.3], list('AAABBBBABCBDDD')]).T
with open('test.html', 'w') as f:
    f.write(HEADER)
    f.write(df.to_html(classes='df'))
    f.write(FOOTER)

Now I want to send this as a html e-mail. I tried this. Can not figure out how to attach the html file?


Viewing all articles
Browse latest Browse all 29934

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>