Compare commits
2 Commits
09c44480fa
...
4495bae649
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4495bae649 | ||
|
|
abc363fcd1 |
@ -88,17 +88,17 @@
|
|||||||
" </thead>\n",
|
" </thead>\n",
|
||||||
" <tbody>\n",
|
" <tbody>\n",
|
||||||
" <tr>\n",
|
" <tr>\n",
|
||||||
" <th>2262</th>\n",
|
" <th>2304</th>\n",
|
||||||
" <td>C202511</td>\n",
|
" <td>C202512</td>\n",
|
||||||
" <td>2025-07-16</td>\n",
|
" <td>2025-08-06</td>\n",
|
||||||
" <td>2025-08-05</td>\n",
|
" <td>2025-08-26</td>\n",
|
||||||
" <td>21</td>\n",
|
" <td>21</td>\n",
|
||||||
" <td>EUDORA</td>\n",
|
" <td>EUDORA</td>\n",
|
||||||
" <td>2025-07-16</td>\n",
|
" <td>2025-08-06</td>\n",
|
||||||
" <td>11</td>\n",
|
" <td>12</td>\n",
|
||||||
" <td>C2025</td>\n",
|
" <td>C2025</td>\n",
|
||||||
" <td>C202514</td>\n",
|
" <td>C202515</td>\n",
|
||||||
" <td>54</td>\n",
|
" <td>62</td>\n",
|
||||||
" <td>1</td>\n",
|
" <td>1</td>\n",
|
||||||
" </tr>\n",
|
" </tr>\n",
|
||||||
" </tbody>\n",
|
" </tbody>\n",
|
||||||
@ -107,10 +107,10 @@
|
|||||||
],
|
],
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
" Ciclo INICIO CICLO FIM CICLO DURAÇÃO MARCA Date NUM_CICLO \\\n",
|
" Ciclo INICIO CICLO FIM CICLO DURAÇÃO MARCA Date NUM_CICLO \\\n",
|
||||||
"2262 C202511 2025-07-16 2025-08-05 21 EUDORA 2025-07-16 11 \n",
|
"2304 C202512 2025-08-06 2025-08-26 21 EUDORA 2025-08-06 12 \n",
|
||||||
"\n",
|
"\n",
|
||||||
" ANO_CICLO CICLOMAIS2 dias_ate_inicio match \n",
|
" ANO_CICLO CICLOMAIS2 dias_ate_inicio match \n",
|
||||||
"2262 C2025 C202514 54 1 "
|
"2304 C2025 C202515 62 1 "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 3,
|
"execution_count": 3,
|
||||||
@ -263,7 +263,7 @@
|
|||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_61796\\3284054138.py:10: DtypeWarning: Columns (7) have mixed types. Specify dtype option on import or set low_memory=False.\n",
|
"C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_27244\\3284054138.py:10: DtypeWarning: Columns (7) have mixed types. Specify dtype option on import or set low_memory=False.\n",
|
||||||
" df_draft = pd.concat([pd.read_csv(file) for file in csv_files], ignore_index=True)\n"
|
" df_draft = pd.concat([pd.read_csv(file) for file in csv_files], ignore_index=True)\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -354,7 +354,7 @@
|
|||||||
"name": "stderr",
|
"name": "stderr",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_61796\\1463083786.py:24: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
"C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_27244\\1463083786.py:24: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
||||||
" crescimento_por_pdv = df_draft.groupby('PDV').apply(calcular_crescimento)\n"
|
" crescimento_por_pdv = df_draft.groupby('PDV').apply(calcular_crescimento)\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1264,10 +1264,10 @@
|
|||||||
" 'Histórico de Vendas do Ciclo 202504',\n",
|
" 'Histórico de Vendas do Ciclo 202504',\n",
|
||||||
" 'Histórico de Vendas do Ciclo 202505',\n",
|
" 'Histórico de Vendas do Ciclo 202505',\n",
|
||||||
" 'Histórico de Vendas do Ciclo 202506',\n",
|
" 'Histórico de Vendas do Ciclo 202506',\n",
|
||||||
" 'Histórico de Vendas do Ciclo Atual',\n",
|
" 'Histórico de Vendas do Ciclo Atual', 'Projeção Próximo Ciclo',\n",
|
||||||
" 'Histórico de Vendas do Ciclo 202507', 'Vendas Ciclo Lançamento',\n",
|
" 'Projeção Próximo Ciclo + 1', 'Histórico de Vendas do Ciclo 202507',\n",
|
||||||
" 'Pico Vendas Similar Ultimos 6 ciclos', 'MEDIANA DO HISTÓRICO',\n",
|
" 'Vendas Ciclo Lançamento', 'Pico Vendas Similar Ultimos 6 ciclos',\n",
|
||||||
" 'PDVDEPARA.Practico', 'Código', 'PV GINSENG'],\n",
|
" 'MEDIANA DO HISTÓRICO', 'PDVDEPARA.Practico', 'Código', 'PV GINSENG'],\n",
|
||||||
" dtype='object')"
|
" dtype='object')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1280,7 +1280,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"df_final.drop(columns=['status', 'Classe', 'SKU', 'Subcategoria', 'Lançamento',\n",
|
"df_final.drop(columns=['status', 'Classe', 'SKU', 'Subcategoria', 'Lançamento',\n",
|
||||||
" 'Desativação','Dias sem venda',\n",
|
" 'Desativação','Dias sem venda',\n",
|
||||||
" 'Projeção Próximo Ciclo', 'Projeção Próximo Ciclo + 1',\n",
|
" #'Projeção Próximo Ciclo', 'Projeção Próximo Ciclo + 1',\n",
|
||||||
" 'Promoção Próximo Ciclo', 'Promoção Próximo Ciclo + 1', 'Estoque Atual',\n",
|
" 'Promoção Próximo Ciclo', 'Promoção Próximo Ciclo + 1', 'Estoque Atual',\n",
|
||||||
" 'Estoque em Transito', 'Pedido Pendente',\n",
|
" 'Estoque em Transito', 'Pedido Pendente',\n",
|
||||||
" 'Compra inteligente semanal/Sugestão de compra',\n",
|
" 'Compra inteligente semanal/Sugestão de compra',\n",
|
||||||
@ -1346,6 +1346,7 @@
|
|||||||
" 'MECANICA REVENDEDOR', 'TIPO DE PRODUTO', 'MATCH', 'PDV', 'CANAL',\n",
|
" 'MECANICA REVENDEDOR', 'TIPO DE PRODUTO', 'MATCH', 'PDV', 'CANAL',\n",
|
||||||
" 'DESCRIÇÃO PDV', 'PDV DESC', 'UF', 'ANALISTA', 'SUPERVISOR',\n",
|
" 'DESCRIÇÃO PDV', 'PDV DESC', 'UF', 'ANALISTA', 'SUPERVISOR',\n",
|
||||||
" 'DESCRIÇÃO', 'C-4', 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL',\n",
|
" 'DESCRIÇÃO', 'C-4', 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL',\n",
|
||||||
|
" 'PROJEÇÃO PRÓXIMO CICLO', 'PROJEÇÃO PRÓXIMO CICLO + 1',\n",
|
||||||
" 'VENDAS CICLO LANÇAMENTO', 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n",
|
" 'VENDAS CICLO LANÇAMENTO', 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n",
|
||||||
" 'MEDIANA DO HISTÓRICO', 'PDVDEPARA.PRACTICO', 'CÓDIGO', 'PV GINSENG'],\n",
|
" 'MEDIANA DO HISTÓRICO', 'PDVDEPARA.PRACTICO', 'CÓDIGO', 'PV GINSENG'],\n",
|
||||||
" dtype='object')"
|
" dtype='object')"
|
||||||
@ -1366,12 +1367,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 45,
|
||||||
"id": "5abd4bae",
|
"id": "5abd4bae",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"df_final = df_final.drop(columns=['DESCRIÇÃO','MEDIANA DO HISTÓRICO','SKU'])"
|
"df_final = df_final.drop(columns=['DESCRIÇÃO','MEDIANA DO HISTÓRICO'])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1383,7 +1384,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"(170, 32)"
|
"(170, 34)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 46,
|
"execution_count": 46,
|
||||||
@ -1398,6 +1399,36 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 47,
|
"execution_count": 47,
|
||||||
|
"id": "10975651",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"Index(['PRODUTO LANÇAMENTO', 'DESCRIÇÃO DO LANÇAMENTO', 'PRODUTO SIMILAR',\n",
|
||||||
|
" 'DESCRIÇÃO SIMILAR', 'CICLO SIMILAR', 'FOCO', 'IAF', 'CATEGORIA',\n",
|
||||||
|
" 'MARCA', '% CONSUMIDOR', 'MECANICA CONSUMIDOR', '% REVENDEDOR',\n",
|
||||||
|
" 'MECANICA REVENDEDOR', 'TIPO DE PRODUTO', 'MATCH', 'PDV', 'CANAL',\n",
|
||||||
|
" 'DESCRIÇÃO PDV', 'PDV DESC', 'UF', 'ANALISTA', 'SUPERVISOR', 'C-4',\n",
|
||||||
|
" 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL', 'PROJEÇÃO PRÓXIMO CICLO',\n",
|
||||||
|
" 'PROJEÇÃO PRÓXIMO CICLO + 1', 'VENDAS CICLO LANÇAMENTO',\n",
|
||||||
|
" 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS', 'PDVDEPARA.PRACTICO', 'CÓDIGO',\n",
|
||||||
|
" 'PV GINSENG'],\n",
|
||||||
|
" dtype='object')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 47,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"df_final.columns"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 48,
|
||||||
"id": "25cbff26",
|
"id": "25cbff26",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -1431,12 +1462,14 @@
|
|||||||
" 'C-1',\n",
|
" 'C-1',\n",
|
||||||
" 'VENDAS CICLO ATUAL',\n",
|
" 'VENDAS CICLO ATUAL',\n",
|
||||||
" 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n",
|
" 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n",
|
||||||
" 'PV GINSENG'])\n"
|
" 'PV GINSENG',\n",
|
||||||
|
" 'PROJEÇÃO PRÓXIMO CICLO',\n",
|
||||||
|
" 'PROJEÇÃO PRÓXIMO CICLO + 1'])\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 48,
|
"execution_count": 49,
|
||||||
"id": "a3e80cb4",
|
"id": "a3e80cb4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -1448,13 +1481,29 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 49,
|
"execution_count": 50,
|
||||||
"id": "2df3e2e9",
|
"id": "2df3e2e9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"df_final.to_excel(r'C:\\Users\\joao.herculano\\Documents\\sugestEUD.xlsx',index=False)"
|
"df_final.to_excel(r'C:\\Users\\joao.herculano\\Documents\\sugestEUD.xlsx',index=False)"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "7d781cb5",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "a40ff37f",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
@ -155,6 +155,39 @@ df4['data'] = hoje
|
|||||||
|
|
||||||
path2 = r'C:\Users\joao.herculano\OneDrive - GRUPO GINSENG\Documentos\acompanhamentos\estudo ruptura\AcompanhamentoRuptura.xlsx'
|
path2 = r'C:\Users\joao.herculano\OneDrive - GRUPO GINSENG\Documentos\acompanhamentos\estudo ruptura\AcompanhamentoRuptura.xlsx'
|
||||||
|
|
||||||
|
de_effi = pd.read_excel(r"C:\Users\joao.herculano\OneDrive - GRUPO GINSENG\Documentos\acompanhamentos\estudo ruptura\AcompanhamentoRuptura.xlsx")
|
||||||
|
|
||||||
|
de_effi['data'] = pd.to_datetime(de_effi['data'], errors='coerce')
|
||||||
|
|
||||||
|
# Step 2: Group and sort
|
||||||
|
grouped = (
|
||||||
|
de_effi.groupby('data')['quantidade_ruptura']
|
||||||
|
.sum()
|
||||||
|
.sort_index()
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 3: Plot
|
||||||
|
plt.figure(figsize=(12, 6))
|
||||||
|
plt.plot(grouped.index, grouped.values, marker='o', linestyle='-', color='cornflowerblue', linewidth=2)
|
||||||
|
|
||||||
|
# Step 4: Format numbers with dot ('.') separator, no decimals
|
||||||
|
for x, y in zip(grouped.index, grouped.values):
|
||||||
|
label = f"{y:,.0f}".replace(",", ".") # format like 75.063
|
||||||
|
plt.text(x, y + max(grouped.values) * 0.015, label, ha='center', fontsize=9)
|
||||||
|
|
||||||
|
# Step 5: Format chart
|
||||||
|
plt.title('Evolução de Quantidade de Ruptura por Data', fontsize=14)
|
||||||
|
plt.xlabel('Data', fontsize=12)
|
||||||
|
plt.ylabel('Quantidade de Ruptura', fontsize=12)
|
||||||
|
plt.grid(True, linestyle='--', alpha=0.6)
|
||||||
|
plt.xticks(rotation=45)
|
||||||
|
|
||||||
|
# Format x-axis as dd/mm/yyyy
|
||||||
|
plt.gca().set_xticklabels([d.strftime('%d/%m/%Y') for d in grouped.index])
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.savefig("grafico2.png")
|
||||||
|
plt.close()
|
||||||
|
|
||||||
# Tenta abrir e escrever com append
|
# Tenta abrir e escrever com append
|
||||||
with pd.ExcelWriter(path2, mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:
|
with pd.ExcelWriter(path2, mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:
|
||||||
# Encontra a última linha preenchida
|
# Encontra a última linha preenchida
|
||||||
@ -194,6 +227,7 @@ else:
|
|||||||
boa = "Boa noite!"
|
boa = "Boa noite!"
|
||||||
|
|
||||||
grafico_cid = make_msgid()[1:-1]
|
grafico_cid = make_msgid()[1:-1]
|
||||||
|
grafico2_cid = make_msgid()[1:-1]
|
||||||
msg = EmailMessage()
|
msg = EmailMessage()
|
||||||
msg['From'] = remetente
|
msg['From'] = remetente
|
||||||
msg['To'] = ', '.join(destinatarios)
|
msg['To'] = ', '.join(destinatarios)
|
||||||
@ -211,8 +245,9 @@ html_email = f"""
|
|||||||
<li>Maior excesso por estado, assim como o PDV que o possui.</li>
|
<li>Maior excesso por estado, assim como o PDV que o possui.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Além disso, o material destaca as VDs com maior criticidade, permitindo uma atuação direcionada para mitigar impactos e priorizar ações de abastecimento e transferência.</p>
|
<p>Além disso, o material destaca as VDs com maior criticidade, permitindo uma atuação direcionada para mitigar impactos e priorizar ações de abastecimento e transferência.</p>
|
||||||
<p><strong>Importante:</strong> O relatório está em processo de desenvolvimento e pode sofrer mudanças futuras no layout. Ficamos à disposição para esclarecer quaisquer dúvidas.</p>
|
<p><strong>Importante:</strong></p>
|
||||||
|
<p>O relatório está em processo de desenvolvimento e pode sofrer mudanças futuras no layout. Ficamos à disposição para esclarecer quaisquer dúvidas.</p>
|
||||||
|
<p>Foram adicionados ao relatório os PDVs da região de Irecê.</p>
|
||||||
|
|
||||||
<img src="cid:{grafico_cid}">
|
<img src="cid:{grafico_cid}">
|
||||||
</body>
|
</body>
|
||||||
@ -224,6 +259,9 @@ msg.add_alternative(html_email, subtype='html')
|
|||||||
with open("grafico.png", 'rb') as img:
|
with open("grafico.png", 'rb') as img:
|
||||||
msg.get_payload()[1].add_related(img.read(), 'image', 'png', cid=grafico_cid)
|
msg.get_payload()[1].add_related(img.read(), 'image', 'png', cid=grafico_cid)
|
||||||
|
|
||||||
|
with open("grafico2.png", 'rb') as img:
|
||||||
|
msg.get_payload()[1].add_related(img.read(), 'image', 'png', cid=grafico2_cid)
|
||||||
|
|
||||||
with open(excel_path, 'rb') as f:
|
with open(excel_path, 'rb') as f:
|
||||||
msg.add_attachment(
|
msg.add_attachment(
|
||||||
f.read(),
|
f.read(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user