I'm beginning on python and made a course about sending info about sales using outlook. The teacher didn't align the rows, and I would like to know how to do that. I merged the rows by my own and wanted to know if I can merge all info in 1 line of code. I'm from Brazil, so some of my variables and the email text are in Portuguese
import win32com.client as win32
import pandas as pd
#TABELA_VENDAS == sales_table
tabela_vendas = pd.read_excel('H:\Curso Python\Projeto\Vendas.xlsx')
pd.set_option('display.max_columns', None)
print(tabela_vendas)
print('-' * 50)
#FATURAMENTO == REVENUES
faturamento = tabela_vendas[['ID Loja','Valor Final']].groupby('ID Loja').sum()
print(faturamento)
print('-' * 50)
#QUANTIDADE == QUANTITY
quantidade = tabela_vendas[['ID Loja','Quantidade']].groupby('ID Loja').sum()
print(quantidade)
print('-' * 50)
#TICKET_MEDIO == REVENUES/QUANTITY
ticket_medio = (faturamento['Valor Final'] / quantidade['Quantidade']).to_frame()
ticket_medio = ticket_medio.rename(columns={0: 'Ticket Médio'})
print(ticket_medio)
print('-' * 50)
#MERGING ALL TABLES IN 1
tabela_geral = pd.merge(faturamento, quantidade, how='outer', on='ID Loja')
tabela_geral = pd.merge(tabela_geral, ticket_medio, how='outer', on='ID Loja')
print(tabela_geral)
print('-' * 50)
#SENDING EMAIL
outlook = win32.Dispatch("Outlook.Application")
mail = outlook.CreateItem(0)
mail.To = "********@gmail.com"
mail.subject = 'Relatório de vendas por loja:'
mail.HTMLBody = f'''
<p>Prezados,</p>
<p>Segue o relatório de vendas por loja.</p>
<p>Tabela Geral das Lojas</p>
{tabela_geral.to_html(formatters={'Valor Final': 'R${:,.2f}'.format, 'Ticket Médio': 'R${:,.2f}'.format})}
<p>Qualquer dúvida estou a disposição.</p>
<p>Att.,</p>
<p>Pedro</p>
'''
mail.Send()
print('Email enviado!') #email sent