1

I've got a spreadsheet that I'd like to partially include in an HTML email displaying specific totals. I'm not sure how to implement the Pandas table. I've got:

Status
Abandoned
Abandoned
Abandoned
Active
Abandoned

And I'd like to somehow implement this in an HTML email notifying users how many of each exist in the table. Because this is always changing, the values will never be the same amount (but they will always be either "Abandoned" or "Active").

dataframe['Status'].value_counts().to_frame()

Works but I'm not sure how to make this into something that can be parsed in an HTML email. Is there a way to pull out the values for each status field and append them to a list or something so I can just use len(list) as the total number of times the value is displayed in that column?

AGH_TORN
  • 813
  • 17
  • 33
  • Duplicate of https://stackoverflow.com/questions/882712/sending-html-email-using-python?noredirect=1&lq=1 – Alex F Jun 26 '17 at 18:06

1 Answers1

1

Use pd.DataFrame.to_html() to return an html table element

df.to_html()
piRSquared
  • 285,575
  • 57
  • 475
  • 624
  • Thank you! This is exactly what I was looking for! – AGH_TORN Jun 26 '17 at 18:19
  • Sorry, quick follow-up: Is there a way to change the output style of the html table? I believe it's through `DataFrame.style` but I'm not sure how that works. Mainly I'm just looking to change the typeface. – AGH_TORN Jun 26 '17 at 18:35
  • It's not a quick answer. See https://stackoverflow.com/a/42245899/2336654 and https://stackoverflow.com/a/38511805/2336654 – piRSquared Jun 26 '17 at 18:37
  • @user88554 also, feel free to up-vote this answer and any others you find useful. You now have more than 15 reputation which gives you 40 votes a day. – piRSquared Jun 26 '17 at 18:38
  • Oh awesome! Thanks for the tips! I can't comment on that post yet but is there a way to incorporate a font change in there instead of a text color change? I'm really unfamiliar with HTML and CSS. – AGH_TORN Jun 26 '17 at 21:56