rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
422 stars 78 forks source link

Unable to send stylized msg using pandas #80

Closed vishal180197 closed 3 years ago

vishal180197 commented 3 years ago

So i am trying to send an automated MSG to Microsoft Teams using pymsteams , I have a Dataframe on which i am applying certain logic an final df is something like this


a b c d
1 2 7 8
0 3 4 6
9 2 1 0

Now when i am sending to pymsteams like this it works

df=df.to_html()
web_hook = 'my_webhook'
myTeamsMessage = pymsteams.connectorcard(web_hook)
myTeamMessage.title("Today's Status")
myTeamsMessage.text("test")
myMessageSection = pymsteams.cardsection()
myMessageSection.title("test")
myMessageSection.text(df)
myTeamsMessage.addSection(myMessageSection)
myTeamsMessage.send()

Now i need to add a background color/text color to the table that is being generated according to some values for example -> all values > 5 should come as red . I tried to achieve this using

df=df.style.apply(custom_func)
df=df.render()
web_hook = 'my_webhook'
myTeamsMessage = pymsteams.connectorcard(web_hook)
myTeamMessage.title("Today's Status")
myTeamsMessage.text("test")
myMessageSection = pymsteams.cardsection()
myMessageSection.title("test")
myMessageSection.text(df)
myTeamsMessage.addSection(myMessageSection)
myTeamsMessage.send()

But this sends a blank message with just the title and section title , the data is not displayed , anyway i can achieve this? Any help or any pointer would be greatly appreciated

rveachkc commented 3 years ago

Pandas DataFrame.style objects render to html, which is not supported by the connector card api.