{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "6ad35669", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np \n", "import glob\n", "import os " ] }, { "cell_type": "code", "execution_count": 2, "id": "9fcdc77a", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_14608\\3809688609.py:3: UserWarning: Parsing dates in %d/%m/%Y format when dayfirst=False (the default) was specified. Pass `dayfirst=True` or specify a format to silence this warning.\n", " calendario['Date'] = pd.to_datetime(calendario['Date'])\n" ] } ], "source": [ "calendario = pd.read_csv(r\"C:\\Users\\joao.herculano\\Documents\\ciclo_calendario_expandido.csv\",sep=';')\n", "\n", "calendario['Date'] = pd.to_datetime(calendario['Date'])\n", "\n", "# Get today (normalized to midnight)\n", "today = pd.Timestamp(\"today\").normalize()\n", "\n", "calendario['NUM_CICLO'] = calendario['Ciclo'].str[-2:].astype(int)\n", "\n", "calendario['ANO_CICLO'] = calendario['Ciclo'].str[0:5]\n", "\n", "calendario = calendario[calendario['MARCA'] == \"QDB\"]\n", "\n", "calendario['CICLOMAIS2'] = calendario['ANO_CICLO'].astype(str) + (calendario['NUM_CICLO'].astype(int) + 2).astype(str).str.zfill(2) #<<< MUDAR O \"+2\" (CICLO ATUAL + 4 PARA ACHAR O CICLO DA SUGESTÃO) EX: C202505 -> C202509\n", "ciclo_mais2 = calendario[calendario['Date'].dt.normalize() == today]['CICLOMAIS2'].iloc[0]\n", "\n", "# Filter rows where date matches today\n", "filtered_calendario = calendario[calendario['Ciclo'] == ciclo_mais2][:1] #\"C202514\"\n", "\n", "inicio_ciclo = pd.to_datetime(filtered_calendario['INICIO CICLO'].iloc[0], format='%d/%m/%Y')\n", "filtered_calendario['dias_ate_inicio'] = (inicio_ciclo - today).days\n", "\n", "filtered_calendario['match'] = 1\n", "\n", "filtered_calendario = filtered_calendario.drop(columns='id')\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "910c3ff6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CicloINICIO CICLOFIM CICLODURAÇÃOMARCADateNUM_CICLOANO_CICLOCICLOMAIS2dias_ate_iniciomatch
4706C20251401/12/202525/12/202525QDB2025-12-0114C2025C202516451
\n", "
" ], "text/plain": [ " Ciclo INICIO CICLO FIM CICLO DURAÇÃO MARCA Date NUM_CICLO \\\n", "4706 C202514 01/12/2025 25/12/2025 25 QDB 2025-12-01 14 \n", "\n", " ANO_CICLO CICLOMAIS2 dias_ate_inicio match \n", "4706 C2025 C202516 45 1 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "filtered_calendario" ] }, { "cell_type": "code", "execution_count": 4, "id": "61ffc777", "metadata": {}, "outputs": [], "source": [ "df_similares = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\QDB_EAM\\QDB - C14\\arquivos para geração da sugestão\\SIMILARES\\PRODUTOS SIMILARES - QDB.xlsx\")\n", "\n", "df_similares = pd.merge(left=df_similares,right=calendario[['Ciclo','INICIO CICLO','FIM CICLO','DURAÇÃO']], how= 'left', left_on = 'CICLO SIMILAR',right_on = 'Ciclo' )\n", "\n", "df_similares = df_similares.drop(columns=['Ciclo'])\n", "\n", "df_similares = df_similares.rename(columns={'INICIO CICLO':'INICIO CICLO SIMILAR','FIM CICLO':'FIM CICLO SIMILAR','DURAÇÃO':'DURAÇÃO CICLO SIMILAR'})\n", "df_similares.drop_duplicates(inplace=True)\n", "\n", "df_similares['MATCH'] = 1\n", "\n", "df_similares = df_similares.drop(columns=['INICIO DO CICLO',\n", " 'FIM DO CICLO', 'DURAÇÃO CICLO','INICIO CICLO SIMILAR','FIM CICLO SIMILAR','DURAÇÃO CICLO SIMILAR'])" ] }, { "cell_type": "code", "execution_count": 5, "id": "99ea95e6", "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'],\n", " dtype='object')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_similares.columns" ] }, { "cell_type": "code", "execution_count": 6, "id": "fe922f62", "metadata": {}, "outputs": [], "source": [ "df_tabela = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\QDB_EAM\\QDB - C14\\arquivos para geração da sugestão\\TABELA DE PEDIDO\\Pedidos Semanais Especiais - QDB - 202514.xlsx\")\n", "\n", "df_tabela = df_tabela[df_tabela['Região'] == 'NNE'] \n", "\n", "df_tabela = df_tabela[(df_tabela['Canal'] != 'Ecomm') | (df_tabela['Canal'] != 'Ecomm | VD') | (df_tabela['Canal'] != 'Ecomm | Loja')] \n", "\n", "df_tabela['Canal'] = np.where((df_tabela['Canal'] == \"Loja\") | (df_tabela['Canal'] == \"Todos\") | (df_tabela['Canal'] == \"Loja | VD\"),\"TODOS\",\"VD\")\n", "\n", "#df_tabela = df_tabela[df_tabela['Tipo de promoção'].str.contains('Lançamentos', na=False)]" ] }, { "cell_type": "code", "execution_count": 7, "id": "a3a045d9", "metadata": {}, "outputs": [], "source": [ "df_pdv = pd.read_excel(r\"C:\\Users\\joao.herculano\\Documents\\PDV_ATT.xlsx\")\n", "\n", "df_pdv_origi = pd.read_excel(r\"C:\\Users\\joao.herculano\\Documents\\PDV_ATT.xlsx\")\n", "\n", "df_pdv = df_pdv.rename(columns={'DESCRIÇÃO':'DESCRIÇÃO PDV'})\n", "\n", "df_pdv = df_pdv.drop(columns=['REGIÃO', 'ESTADO','CIDADE','GESTÃO','MARCA'])\n", "\n", "df_pdv = df_pdv[df_pdv['CANAL'].isin(['HIB','VD', 'CD'])]\n", "\n", "#df_pdv = df_pdv[df_pdv['PDV'].isin([910291,910173])]\n", "\n", "df_pdv = df_pdv[df_pdv['STATUS'] == 'ATIVO']\n", "\n", "df_pdv['PDV DESC'] = df_pdv['DESCRIÇÃO PDV']\n", "\n", "df_pdv['MATCH'] = 1" ] }, { "cell_type": "code", "execution_count": 8, "id": "737ade5c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PDVCANALDESCRIÇÃO PDVPDV DESCUFANALISTASUPERVISORSTATUSANALISTA EUDMATCH
2620968HIBHIB ITABAIANINHAHIB ITABAIANINHASEMARCYARATaciana AndradeATIVODIELLY1
2720969HIBHIB MARECHAL DEODHIB MARECHAL DEODALTHAYLLANEfigênia HerculanoATIVOHARY1
2820970VDER SAO SEBASTIAOER SAO SEBASTIAOBAMARCYARAFERNANDAATIVODIELLY1
2920986HIBHIB OLINDINAHIB OLINDINABALUCASCLÁUDIAATIVOHARY1
3020988HIBHIB QUEIMADASHIB QUEIMADASBALUANCLÁUDIAATIVOHARY1
3120989HIBHIB ENTRE RIOSHIB ENTRE RIOSBAMARCYARACLÁUDIAATIVODIELLY1
3220991HIBHIB CAMPO ALEGREHIB CAMPO ALEGREALTHAYLLANEfigênia HerculanoATIVOHARY1
3320992VDER CONC COITEER CONC COITEBAJEFFERSONCLÁUDIAATIVOHARY1
3420993VDER CANDEIASER CANDEIASBAMARCYARAFERNANDAATIVODIELLY1
3520994VDER SIMOES FILHOER SIMOES FILHOBALUCASFERNANDAATIVOHARY1
3620995VDER LAGARTOER LAGARTOSEMARCYARATaciana AndradeATIVODIELLY1
3720996VDER ANTARESER ANTARESALJEFFERSONAnna SchellyATIVODIELLY1
3820997VDER PITANGUINHAER PITANGUINHAALLUCASAnna SchellyATIVODIELLY1
3920998CDCD SERRARIACD SERRARIAALVAAnna SchellyATIVOVA1
4020999HIBHIB ESPLANADAHIB ESPLANADABAMARCYARACLÁUDIAATIVODIELLY1
4121000HIBHIB SANTALUZHIB SANTALUZBALUCASCLÁUDIAATIVODIELLY1
4221001HIBHIB RIO REALHIB RIO REALBALUCASCLÁUDIAATIVOHARY1
4621278VDVD SOCORROVD SOCORROSEJEFFERSONCarla MeloATIVOHARY1
4821375HIBIPIRA HBIPIRA HBBALUCASFERNANDAATIVOHARY1
5121383VDCAPIM GROSSO ERCAPIM GROSSO ERBALUANFERNANDAATIVODIELLY1
5221495HIBVD BARRA DOS COQVD BARRA DOS COQSEJEFFERSONCarla MeloATIVOHARY1
5622541VDER RIO LARGOER RIO LARGOALJEFFERSONAnna SchellyATIVODIELLY1
6223704VDER CONDEUBAER CONDEUBAVDCMARCYARAJACQUELINEATIVODIELLY1
6623708HIBHIB BARRA DO CHOCAHIB BARRA DO CHOCAVDCLUANJACQUELINEATIVOHARY1
6923711VDER VITORIA DA CONQUISTAER VITORIA DA CONQUISTAVDCVAJACQUELINEATIVOVA1
7023712HIBHIB CANDIDO SALESHIB CANDIDO SALESVDCLUCASJACQUELINEATIVOHARY1
7724255VDVD IrecêVD IrecêBA3JEFFERSONJOAQUIMATIVODIELLY1
7924257HIBMiguel CalmonMiguel CalmonBA3THAYLLANFERNANDAATIVOHARY1
8124269VDCOMERCIO-ER JACOBINACOMERCIO-ER JACOBINABA3JEFFERSONFERNANDAATIVOHARY1
8224293HIBCOMERCIO-HIB MORRO DO CHAPEUCOMERCIO-HIB MORRO DO CHAPEUBA3MARCYARAFERNANDAATIVODIELLY1
8523813HIBVALENTEVALENTEBAMARCYARACLÁUDIAATIVOHARY1
\n", "
" ], "text/plain": [ " PDV CANAL DESCRIÇÃO PDV PDV DESC \\\n", "26 20968 HIB HIB ITABAIANINHA HIB ITABAIANINHA \n", "27 20969 HIB HIB MARECHAL DEOD HIB MARECHAL DEOD \n", "28 20970 VD ER SAO SEBASTIAO ER SAO SEBASTIAO \n", "29 20986 HIB HIB OLINDINA HIB OLINDINA \n", "30 20988 HIB HIB QUEIMADAS HIB QUEIMADAS \n", "31 20989 HIB HIB ENTRE RIOS HIB ENTRE RIOS \n", "32 20991 HIB HIB CAMPO ALEGRE HIB CAMPO ALEGRE \n", "33 20992 VD ER CONC COITE ER CONC COITE \n", "34 20993 VD ER CANDEIAS ER CANDEIAS \n", "35 20994 VD ER SIMOES FILHO ER SIMOES FILHO \n", "36 20995 VD ER LAGARTO ER LAGARTO \n", "37 20996 VD ER ANTARES ER ANTARES \n", "38 20997 VD ER PITANGUINHA ER PITANGUINHA \n", "39 20998 CD CD SERRARIA CD SERRARIA \n", "40 20999 HIB HIB ESPLANADA HIB ESPLANADA \n", "41 21000 HIB HIB SANTALUZ HIB SANTALUZ \n", "42 21001 HIB HIB RIO REAL HIB RIO REAL \n", "46 21278 VD VD SOCORRO VD SOCORRO \n", "48 21375 HIB IPIRA HB IPIRA HB \n", "51 21383 VD CAPIM GROSSO ER CAPIM GROSSO ER \n", "52 21495 HIB VD BARRA DOS COQ VD BARRA DOS COQ \n", "56 22541 VD ER RIO LARGO ER RIO LARGO \n", "62 23704 VD ER CONDEUBA ER CONDEUBA \n", "66 23708 HIB HIB BARRA DO CHOCA HIB BARRA DO CHOCA \n", "69 23711 VD ER VITORIA DA CONQUISTA ER VITORIA DA CONQUISTA \n", "70 23712 HIB HIB CANDIDO SALES HIB CANDIDO SALES \n", "77 24255 VD VD Irecê VD Irecê \n", "79 24257 HIB Miguel Calmon Miguel Calmon \n", "81 24269 VD COMERCIO-ER JACOBINA COMERCIO-ER JACOBINA \n", "82 24293 HIB COMERCIO-HIB MORRO DO CHAPEU COMERCIO-HIB MORRO DO CHAPEU \n", "85 23813 HIB VALENTE VALENTE \n", "\n", " UF ANALISTA SUPERVISOR STATUS ANALISTA EUD MATCH \n", "26 SE MARCYARA Taciana Andrade ATIVO DIELLY 1 \n", "27 AL THAYLLAN Efigênia Herculano ATIVO HARY 1 \n", "28 BA MARCYARA FERNANDA ATIVO DIELLY 1 \n", "29 BA LUCAS CLÁUDIA ATIVO HARY 1 \n", "30 BA LUAN CLÁUDIA ATIVO HARY 1 \n", "31 BA MARCYARA CLÁUDIA ATIVO DIELLY 1 \n", "32 AL THAYLLAN Efigênia Herculano ATIVO HARY 1 \n", "33 BA JEFFERSON CLÁUDIA ATIVO HARY 1 \n", "34 BA MARCYARA FERNANDA ATIVO DIELLY 1 \n", "35 BA LUCAS FERNANDA ATIVO HARY 1 \n", "36 SE MARCYARA Taciana Andrade ATIVO DIELLY 1 \n", "37 AL JEFFERSON Anna Schelly ATIVO DIELLY 1 \n", "38 AL LUCAS Anna Schelly ATIVO DIELLY 1 \n", "39 AL VA Anna Schelly ATIVO VA 1 \n", "40 BA MARCYARA CLÁUDIA ATIVO DIELLY 1 \n", "41 BA LUCAS CLÁUDIA ATIVO DIELLY 1 \n", "42 BA LUCAS CLÁUDIA ATIVO HARY 1 \n", "46 SE JEFFERSON Carla Melo ATIVO HARY 1 \n", "48 BA LUCAS FERNANDA ATIVO HARY 1 \n", "51 BA LUAN FERNANDA ATIVO DIELLY 1 \n", "52 SE JEFFERSON Carla Melo ATIVO HARY 1 \n", "56 AL JEFFERSON Anna Schelly ATIVO DIELLY 1 \n", "62 VDC MARCYARA JACQUELINE ATIVO DIELLY 1 \n", "66 VDC LUAN JACQUELINE ATIVO HARY 1 \n", "69 VDC VA JACQUELINE ATIVO VA 1 \n", "70 VDC LUCAS JACQUELINE ATIVO HARY 1 \n", "77 BA3 JEFFERSON JOAQUIM ATIVO DIELLY 1 \n", "79 BA3 THAYLLAN FERNANDA ATIVO HARY 1 \n", "81 BA3 JEFFERSON FERNANDA ATIVO HARY 1 \n", "82 BA3 MARCYARA FERNANDA ATIVO DIELLY 1 \n", "85 BA MARCYARA CLÁUDIA ATIVO HARY 1 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_pdv" ] }, { "cell_type": "code", "execution_count": 9, "id": "849d5297", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['PDV', 'CANAL', 'DESCRIÇÃO PDV', 'PDV DESC', 'UF', 'ANALISTA',\n", " 'SUPERVISOR', 'STATUS', 'ANALISTA EUD', 'MATCH'],\n", " dtype='object')" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_pdv.columns" ] }, { "cell_type": "code", "execution_count": 10, "id": "df04a501", "metadata": {}, "outputs": [], "source": [ "df_similares = pd.merge(left=df_similares,right=df_pdv,right_on=['MATCH'],left_on=['MATCH'],how='inner')\n", "\n", "df_similares = df_similares.drop_duplicates()" ] }, { "cell_type": "code", "execution_count": 11, "id": "0da911af", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_14608\\1168637187.py:10: DtypeWarning: Columns (6) 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" ] }, { "data": { "text/plain": [ "(83561, 47)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Caminho onde estão as subpastas com os arquivos CSV\n", "\n", "# Set the path to the folder containing CSV files\n", "folder_path = r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\QDB_EAM\\QDB - C13\\arquivos para geração da sugestão\\DRAFT\" # arquivo dos drafts\n", "\n", "# Pattern to match all CSV files\n", "csv_files = glob.glob(os.path.join(folder_path, '*.csv'))\n", "\n", "# Read and concat all CSVs\n", "df_draft = pd.concat([pd.read_csv(file) for file in csv_files], ignore_index=True)\n", "\n", "df_draft['match'] = 1 \n", "\n", "df_draft.shape\n" ] }, { "cell_type": "code", "execution_count": 12, "id": "0c8c7493", "metadata": {}, "outputs": [], "source": [ "df_draft = df_draft.drop(columns=['Categoria'])" ] }, { "cell_type": "code", "execution_count": 13, "id": "91298cde", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Histórico de Vendas do Ciclo 202413',\n", " 'Histórico de Vendas do Ciclo 202414',\n", " 'Histórico de Vendas do Ciclo 202415',\n", " 'Histórico de Vendas do Ciclo 202416',\n", " 'Histórico de Vendas do Ciclo 202417',\n", " 'Histórico de Vendas do Ciclo 202501',\n", " 'Histórico de Vendas do Ciclo 202502',\n", " 'Histórico de Vendas do Ciclo 202503',\n", " 'Histórico de Vendas do Ciclo 202504',\n", " 'Histórico de Vendas do Ciclo 202505',\n", " 'Histórico de Vendas do Ciclo 202506',\n", " 'Histórico de Vendas do Ciclo 202507',\n", " 'Histórico de Vendas do Ciclo 202508',\n", " 'Histórico de Vendas do Ciclo 202509',\n", " 'Histórico de Vendas do Ciclo 202510',\n", " 'Histórico de Vendas do Ciclo 202511',\n", " 'Histórico de Vendas do Ciclo 202512',\n", " 'Histórico de Vendas do Ciclo Atual'],\n", " dtype='object')" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_draft.columns[7:25]" ] }, { "cell_type": "code", "execution_count": 14, "id": "34e179cb", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_14608\\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" ] } ], "source": [ "# Define as colunas mensais\n", "colunas_mensais = df_draft.columns[7:25]\n", "\n", "# Agrupa por PDV e calcula crescimento médio por PDV\n", "def calcular_crescimento(grupo):\n", " soma_mensal = grupo[colunas_mensais].sum() # soma por mês\n", " variacao_mensal = soma_mensal.pct_change().dropna() # variação percentual mês a mês\n", " variacao_mensal = variacao_mensal[np.isfinite(variacao_mensal)]\n", "\n", " if len(variacao_mensal) == 0:\n", " return pd.Series({'CRESCIMENTO': np.nan})\n", "\n", " media = variacao_mensal.mean()\n", " desvio = variacao_mensal.std()\n", "\n", " limite_sup = media + 2 * desvio\n", " limite_inf = media - 2 * desvio\n", "\n", " variacoes_filtradas = variacao_mensal[variacao_mensal.between(limite_inf, limite_sup)]\n", " crescimento = round(variacoes_filtradas.mean(), 4)\n", " return pd.Series({'CRESCIMENTO': crescimento})\n", "\n", "# Aplica a função por PDV\n", "crescimento_por_pdv = df_draft.groupby('PDV').apply(calcular_crescimento)\n", "\n", "# Merge do resultado de volta no dataframe original\n", "df_draft = df_draft.merge(crescimento_por_pdv, on='PDV', how='left')\n" ] }, { "cell_type": "code", "execution_count": 15, "id": "4bc8c2b4", "metadata": {}, "outputs": [], "source": [ "df_similares['PDV'] = df_similares['PDV'].astype('Int64')\n", "\n", "df_final = pd.merge(left=df_similares,right=df_draft,right_on=['PDV', 'SKU'],left_on=['PDV','PRODUTO SIMILAR'],how='left')" ] }, { "cell_type": "code", "execution_count": 68, "id": "191bbff1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SUPERVISORCANALUFPDVPDV DESCPRODUTO LANÇAMENTODESCRIÇÃO DO LANÇAMENTOMARCACATEGORIAMECANICA CONSUMIDOR...C-2C-1VENDAS CICLO ATUALPICO VENDAS SIMILAR ULTIMOS 6 CICLOSPV GINSENGPROJEÇÃO PRÓXIMO CICLOPROJEÇÃO PRÓXIMO CICLO + 1SUGESTÃO METASELLINSUGESTÃO ABASTECIMENTOSUGESTÃO COMERCIAL
0Taciana AndradeHIBSE20968HIB ITABAIANINHA85925PALETA MULTIFUNCIONAL DOSE DE COR 12gQDB DOSE DE CORMAQUIAGEMNaN...0.00.00.00.01.0NaNNaN
1Efigênia HerculanoHIBAL20969HIB MARECHAL DEOD85925PALETA MULTIFUNCIONAL DOSE DE COR 12gQDB DOSE DE CORMAQUIAGEMNaN...0.00.00.00.01.0NaNNaN
2FERNANDAVDBA20970ER SAO SEBASTIAO85925PALETA MULTIFUNCIONAL DOSE DE COR 12gQDB DOSE DE CORMAQUIAGEMNaN...0.00.00.00.02.0NaNNaN
3CLÁUDIAHIBBA20986HIB OLINDINA85925PALETA MULTIFUNCIONAL DOSE DE COR 12gQDB DOSE DE CORMAQUIAGEMNaN...0.00.00.00.01.0NaNNaN
4CLÁUDIAHIBBA20988HIB QUEIMADAS85925PALETA MULTIFUNCIONAL DOSE DE COR 12gQDB DOSE DE CORMAQUIAGEMNaN...0.00.00.00.01.0NaNNaN
\n", "

5 rows × 32 columns

\n", "
" ], "text/plain": [ " SUPERVISOR CANAL UF PDV PDV DESC PRODUTO LANÇAMENTO \\\n", "0 Taciana Andrade HIB SE 20968 HIB ITABAIANINHA 85925 \n", "1 Efigênia Herculano HIB AL 20969 HIB MARECHAL DEOD 85925 \n", "2 FERNANDA VD BA 20970 ER SAO SEBASTIAO 85925 \n", "3 CLÁUDIA HIB BA 20986 HIB OLINDINA 85925 \n", "4 CLÁUDIA HIB BA 20988 HIB QUEIMADAS 85925 \n", "\n", " DESCRIÇÃO DO LANÇAMENTO MARCA CATEGORIA \\\n", "0 PALETA MULTIFUNCIONAL DOSE DE COR 12g QDB DOSE DE COR MAQUIAGEM \n", "1 PALETA MULTIFUNCIONAL DOSE DE COR 12g QDB DOSE DE COR MAQUIAGEM \n", "2 PALETA MULTIFUNCIONAL DOSE DE COR 12g QDB DOSE DE COR MAQUIAGEM \n", "3 PALETA MULTIFUNCIONAL DOSE DE COR 12g QDB DOSE DE COR MAQUIAGEM \n", "4 PALETA MULTIFUNCIONAL DOSE DE COR 12g QDB DOSE DE COR MAQUIAGEM \n", "\n", " MECANICA CONSUMIDOR ... C-2 C-1 VENDAS CICLO ATUAL \\\n", "0 NaN ... 0.0 0.0 0.0 \n", "1 NaN ... 0.0 0.0 0.0 \n", "2 NaN ... 0.0 0.0 0.0 \n", "3 NaN ... 0.0 0.0 0.0 \n", "4 NaN ... 0.0 0.0 0.0 \n", "\n", " PICO VENDAS SIMILAR ULTIMOS 6 CICLOS PV GINSENG PROJEÇÃO PRÓXIMO CICLO \\\n", "0 0.0 1.0 NaN \n", "1 0.0 1.0 NaN \n", "2 0.0 2.0 NaN \n", "3 0.0 1.0 NaN \n", "4 0.0 1.0 NaN \n", "\n", " PROJEÇÃO PRÓXIMO CICLO + 1 SUGESTÃO METASELLIN SUGESTÃO ABASTECIMENTO \\\n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "\n", " SUGESTÃO COMERCIAL \n", "0 \n", "1 \n", "2 \n", "3 \n", "4 \n", "\n", "[5 rows x 32 columns]" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.head()" ] }, { "cell_type": "code", "execution_count": 16, "id": "867eef0d", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_14608\\330515216.py:29: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.\n", " dfi = pd.read_sql(query, conn)\n" ] } ], "source": [ "import pyodbc\n", "import configparser\n", "\n", "\n", "config = configparser.ConfigParser()\n", "config.read(r\"C:\\Users\\joao.herculano\\Documents\\Enviador de email\\credenciais.ini\")\n", "\n", "conn = pyodbc.connect(\n", " f\"DRIVER={{SQL Server}};\"\n", " f\"SERVER={config['banco']['host']},1433;\"\n", " f\"DATABASE=GINSENG;\"\n", " f\"UID={config['banco']['user']};\"\n", " f\"PWD={config['banco']['password']}\"\n", ")\n", "\n", "query = '''\n", "SELECT \n", " b.[DATA] AS Dia,\n", " b.pdv AS PDV,\n", " b.sku as 'Código do Produto',\n", " b.VENDAS AS Quantidade\n", "FROM base_vendas_bi b\n", "LEFT JOIN (\n", " SELECT SKU, MAX(ORIGEM) AS ORIGEM\n", " FROM estoque_mar\n", " GROUP BY SKU\n", ") e ON b.SKU = e.SKU\n", "'''\n", "dfi = pd.read_sql(query, conn)\n", "conn.close()" ] }, { "cell_type": "code", "execution_count": 17, "id": "297526e2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DiaPDVCódigo do ProdutoQuantidade
02025-09-0920998830611
12025-09-1120998830610
22025-09-0620998830611
32025-09-2520998830611
42025-09-2020998830610
\n", "
" ], "text/plain": [ " Dia PDV Código do Produto Quantidade\n", "0 2025-09-09 20998 83061 1\n", "1 2025-09-11 20998 83061 0\n", "2 2025-09-06 20998 83061 1\n", "3 2025-09-25 20998 83061 1\n", "4 2025-09-20 20998 83061 0" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dfi.head()" ] }, { "cell_type": "code", "execution_count": 18, "id": "80021c11", "metadata": {}, "outputs": [], "source": [ "df_venda_diaria = dfi " ] }, { "cell_type": "code", "execution_count": 19, "id": "46accb64", "metadata": {}, "outputs": [], "source": [ "df_venda_diaria['Dia'] = pd.to_datetime(df_venda_diaria['Dia'], errors='coerce').dt.strftime('%d/%m/%Y')" ] }, { "cell_type": "code", "execution_count": 20, "id": "c1451562", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DiaPDVCódigo do ProdutoQuantidade
009/09/202520998830611
111/09/202520998830610
206/09/202520998830611
325/09/202520998830611
420/09/202520998830610
\n", "
" ], "text/plain": [ " Dia PDV Código do Produto Quantidade\n", "0 09/09/2025 20998 83061 1\n", "1 11/09/2025 20998 83061 0\n", "2 06/09/2025 20998 83061 1\n", "3 25/09/2025 20998 83061 1\n", "4 20/09/2025 20998 83061 0" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#df_venda_diaria = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\EUDORA\\C13\\venda diaria\\FormFiltroConsultaVendaSintetica_10_07_2025_15_27_42.xls\")\n", "\n", "df_venda_diaria.head()" ] }, { "cell_type": "code", "execution_count": 21, "id": "7ec747bc", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DiaPDVCódigo do ProdutoQuantidade
009/09/202520998830611
111/09/202520998830610
206/09/202520998830611
325/09/202520998830611
420/09/202520998830610
\n", "
" ], "text/plain": [ " Dia PDV Código do Produto Quantidade\n", "0 09/09/2025 20998 83061 1\n", "1 11/09/2025 20998 83061 0\n", "2 06/09/2025 20998 83061 1\n", "3 25/09/2025 20998 83061 1\n", "4 20/09/2025 20998 83061 0" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_venda_diaria.head()" ] }, { "cell_type": "code", "execution_count": 22, "id": "05c77fd8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dia object\n", "PDV object\n", "Código do Produto int64\n", "Quantidade object\n", "dtype: object" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_venda_diaria.dtypes" ] }, { "cell_type": "code", "execution_count": 23, "id": "eb8e3a26", "metadata": {}, "outputs": [], "source": [ "df_venda_diaria['Quantidade'] = df_venda_diaria['Quantidade'].astype('float')" ] }, { "cell_type": "code", "execution_count": 24, "id": "882e68aa", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Dia', 'PDV', 'Código do Produto', 'Quantidade'], dtype='object')" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_venda_diaria.columns" ] }, { "cell_type": "code", "execution_count": 25, "id": "c7ddaf20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(8307689, 5)" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#df_venda_diaria['PDV'] = df_venda_diaria['Unidade de Negócio'].str.split(\"-\").str[0].str.strip()\n", "\n", "df_venda_diaria['Dia'] = pd.to_datetime(df_venda_diaria['Dia'], format='%d/%m/%Y')\n", "\n", "df_venda_diaria = pd.merge(left=df_venda_diaria,right=calendario[['Ciclo','Date']],left_on='Dia',right_on='Date',how='inner')\n", "\n", "df_venda_diaria = df_venda_diaria.drop(columns='Date')\n", "\n", "df_venda_diaria.shape" ] }, { "cell_type": "code", "execution_count": 26, "id": "7119556a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(8307689, 6)" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 'Dia' já está em formato datetime, então renomeamos para 'Data' diretamente\n", "# ou apenas usamos 'Dia' como referência de data\n", "\n", "# Ordena o DataFrame para garantir que a cumulativa funcione corretamente\n", "df_venda_diaria = df_venda_diaria.sort_values(by=['PDV', 'Código do Produto', 'Dia'])\n", "\n", "# Calcula a quantidade acumulada até o dia para cada grupo\n", "df_venda_diaria['Quantidade Acumulada'] = (\n", " df_venda_diaria\n", " .groupby(['PDV', 'Código do Produto'])['Quantidade']\n", " .cumsum()\n", ") # acumulado por grupo até a data da linha\n", "\n", "df_venda_diaria.shape" ] }, { "cell_type": "code", "execution_count": 27, "id": "c707a1b6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PDVCódigo do ProdutoCicloQuantidade Acumulada
01111148130C2023080.0
11120158729C2025060.0
21120187408C2025040.0
31120187408C2025050.0
41120187408C2025060.0
...............
25166877211087373C20241316.0
2516688807443151C2025040.0
2516689807443151C2025050.0
2516690807448676C2025100.0
2516691807482689C2025100.0
\n", "

2516692 rows × 4 columns

\n", "
" ], "text/plain": [ " PDV Código do Produto Ciclo Quantidade Acumulada\n", "0 11111 48130 C202308 0.0\n", "1 11201 58729 C202506 0.0\n", "2 11201 87408 C202504 0.0\n", "3 11201 87408 C202505 0.0\n", "4 11201 87408 C202506 0.0\n", "... ... ... ... ...\n", "2516687 72110 87373 C202413 16.0\n", "2516688 8074 43151 C202504 0.0\n", "2516689 8074 43151 C202505 0.0\n", "2516690 8074 48676 C202510 0.0\n", "2516691 8074 82689 C202510 0.0\n", "\n", "[2516692 rows x 4 columns]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_venda_diaria = df_venda_diaria.drop_duplicates()\n", "\n", "df_venda_agrupado = df_venda_diaria.groupby(['PDV', 'Código do Produto','Ciclo'])['Quantidade Acumulada'].max().reset_index()\n", "df_venda_agrupado" ] }, { "cell_type": "code", "execution_count": 28, "id": "e2ae413b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(229042652.701)" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_venda_agrupado['Quantidade Acumulada'].sum()" ] }, { "cell_type": "code", "execution_count": 29, "id": "dc452c72", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(124, 76)" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final = pd.merge(left=df_final, right=filtered_calendario[['Ciclo','INICIO CICLO','FIM CICLO','DURAÇÃO','match','dias_ate_inicio']], right_on='match',left_on='MATCH',how='left')\n", "df_final.shape" ] }, { "cell_type": "code", "execution_count": 30, "id": "c260e0e3", "metadata": {}, "outputs": [], "source": [ "#df_final = df_final.drop(columns=['PDV DESC','status','SKU','Descrição','Lançamento','Item analisado','Planograma','Quantidade por caixa'])" ] }, { "cell_type": "code", "execution_count": 31, "id": "8a05450c", "metadata": {}, "outputs": [], "source": [ "df_final = pd.merge(left=df_final, right=calendario[['Ciclo','INICIO CICLO','FIM CICLO','DURAÇÃO']], right_on='Ciclo',left_on='CICLO SIMILAR',how='left')\n", "df_final.shape\n", "\n", "df_final = df_final.drop_duplicates()" ] }, { "cell_type": "code", "execution_count": 32, "id": "cc65edab", "metadata": {}, "outputs": [], "source": [ "\n", "df_venda_agrupado = df_venda_agrupado.rename(columns={'Quantidade Acumulada':'Vendas Ciclo Lançamento'})" ] }, { "cell_type": "code", "execution_count": 33, "id": "c5cd5f42", "metadata": {}, "outputs": [], "source": [ "df_final['PRODUTO LANÇAMENTO'] = df_final['PRODUTO LANÇAMENTO'].astype('Int64')\n", "\n", "df_venda_agrupado['PDV'] = df_venda_agrupado['PDV'].astype('Int64')\n", "\n", "df_final = pd.merge(left=df_final, right = df_venda_agrupado, right_on=['Ciclo','Código do Produto','PDV'],left_on=['CICLO SIMILAR','PRODUTO SIMILAR','PDV'],how='left')\n", "\n", "df_final = df_final.drop_duplicates()" ] }, { "cell_type": "code", "execution_count": 34, "id": "69c88d20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.int64(4)" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final['PDV'].value_counts().min()" ] }, { "cell_type": "code", "execution_count": 35, "id": "f5206f50", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Histórico de Vendas do Ciclo 202414',\n", " 'Histórico de Vendas do Ciclo 202415',\n", " 'Histórico de Vendas do Ciclo 202416',\n", " 'Histórico de Vendas do Ciclo 202417',\n", " 'Histórico de Vendas do Ciclo 202501',\n", " 'Histórico de Vendas do Ciclo 202502',\n", " 'Histórico de Vendas do Ciclo 202503',\n", " 'Histórico de Vendas do Ciclo 202504',\n", " 'Histórico de Vendas do Ciclo 202505',\n", " 'Histórico de Vendas do Ciclo 202506',\n", " 'Histórico de Vendas do Ciclo 202507',\n", " 'Histórico de Vendas do Ciclo 202508',\n", " 'Histórico de Vendas do Ciclo 202509',\n", " 'Histórico de Vendas do Ciclo 202510',\n", " 'Histórico de Vendas do Ciclo 202511',\n", " 'Histórico de Vendas do Ciclo 202512',\n", " 'Histórico de Vendas do Ciclo Atual'],\n", " dtype='object')" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns[31:48]" ] }, { "cell_type": "code", "execution_count": 36, "id": "2a049809", "metadata": {}, "outputs": [], "source": [ "colunas = df_final.columns[31:48]\n", "\n", "df_final[colunas] = df_final[colunas].fillna(0)\n" ] }, { "cell_type": "code", "execution_count": 37, "id": "0a1bb832", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.float64(0.2027)" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Suponha que os meses estão nas colunas 10 a 26 (17 colunas = 17 meses)\n", "colunas_mensais = df_final.columns[31:48]\n", "\n", "# Passo 1: Soma todas as linhas (itens) por mês → resultado: total por mês\n", "soma_mensal = df_final[colunas_mensais].sum()\n", "\n", "# Passo 2: Calcula a variação percentual de um mês para o outro\n", "variacao_mensal = soma_mensal.pct_change()\n", "variacao_mensal = variacao_mensal.dropna()\n", "\n", "variacao_mensal = variacao_mensal[np.isfinite(variacao_mensal)]\n", "\n", "# Passo 3: Calcula a média da variação (ignorando o primeiro NaN)\n", "media_variacao = variacao_mensal[1:].mean()\n", "\n", "# Calcula média e desvio padrão\n", "media = variacao_mensal.mean()\n", "desvio = variacao_mensal.std()\n", "\n", "# Define limite (ex: 2 desvios padrão)\n", "limite_superior = media + 2 * desvio\n", "limite_inferior = media - 2 * desvio\n", "\n", "# Filtra dados dentro do limite\n", "filtro = variacao_mensal.between(limite_inferior, limite_superior)\n", "df_filtrado = variacao_mensal[filtro]\n", "CRESCIMENTO = round(df_filtrado.mean(),4)\n", "\n", "df_final['CRESCIMENTO_GERAL'] = 0.2\n", "\n", "CRESCIMENTO\n" ] }, { "cell_type": "code", "execution_count": 38, "id": "a9647c32", "metadata": {}, "outputs": [], "source": [ "df_final = df_final.drop(columns='Ciclo_y')\n", "\n", "df_final = df_final.rename(columns={'Ciclo_x': 'Ciclo',\t'INICIO CICLO_x': 'INICIO CICLO',\t'FIM CICLO_x':'FIM CICLO' ,'DURAÇÃO_x':'DURAÇÃO',\n", " \t'INICIO CICLO_y': 'INICIO CICLO SIMILAR' ,\t'FIM CICLO_y': 'FIM CICLO SIMILAR','DURAÇÃO_y':'DURAÇÃO CICLO SIMILAR'})" ] }, { "cell_type": "code", "execution_count": 39, "id": "afbea4ac", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Histórico de Vendas do Ciclo 202507',\n", " 'Histórico de Vendas do Ciclo 202508',\n", " 'Histórico de Vendas do Ciclo 202509',\n", " 'Histórico de Vendas do Ciclo 202510',\n", " 'Histórico de Vendas do Ciclo 202511',\n", " 'Histórico de Vendas do Ciclo 202512',\n", " 'Histórico de Vendas do Ciclo Atual'],\n", " dtype='object')" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns[41:48]" ] }, { "cell_type": "code", "execution_count": 40, "id": "8290853c", "metadata": {}, "outputs": [], "source": [ "VENDA_SIMILAR_6_MESES= df_final.columns[41:48]\n", "\n", "df_final['Pico Vendas Similar Ultimos 6 ciclos'] = df_final[VENDA_SIMILAR_6_MESES].max(axis=1)\n", "\n", "\n", "df_final['MEDIANA DO HISTÓRICO'] = df_final[colunas_mensais].dropna().median(axis=1)\n", "\n", "df_final['MEDIA DO HISTÓRICO'] = df_final[colunas_mensais].dropna().mean(axis=1)\n", "\n", "df_final['Vendas Ciclo Lançamento'] = df_final['Vendas Ciclo Lançamento'].fillna(0)" ] }, { "cell_type": "code", "execution_count": 41, "id": "d3228386", "metadata": {}, "outputs": [], "source": [ "df_final['MEDIANA DO HISTÓRICO USADA'] = np.where(df_final['MEDIA DO HISTÓRICO']\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CicloPDVDEPARA.PracticoCódigoDescriçãoQuantidadeQuantidade Acumulada vdc
0C202201237011061SOPHIE LOC HID CPO MOANA 200ml55
1C202201237011078MATCH SRUM CAP POS QUIMICA 50ml11
2C202201237011296PMPCK THE BLEND DES ANTIT AER 2x75g11
3C202201237011302PMPCK LILY DES ANTIT AER 2x75g66
4C202201237011314PMPCK ZAAD DES ANTIT AER 2x75g77
\n", "" ], "text/plain": [ " Ciclo PDVDEPARA.Practico Código Descrição \\\n", "0 C202201 23701 1061 SOPHIE LOC HID CPO MOANA 200ml \n", "1 C202201 23701 1078 MATCH SRUM CAP POS QUIMICA 50ml \n", "2 C202201 23701 1296 PMPCK THE BLEND DES ANTIT AER 2x75g \n", "3 C202201 23701 1302 PMPCK LILY DES ANTIT AER 2x75g \n", "4 C202201 23701 1314 PMPCK ZAAD DES ANTIT AER 2x75g \n", "\n", " Quantidade Quantidade Acumulada vdc \n", "0 5 5 \n", "1 1 1 \n", "2 1 1 \n", "3 6 6 \n", "4 7 7 " ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_vdc=df_vdc.rename(columns={'Practico':'PDVDEPARA.Practico'})\n", "df_vdc.head()" ] }, { "cell_type": "code", "execution_count": 44, "id": "5a827c08", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
PDVDEPARA.PracticoCódigoCiclo vdcQuantidade Acumulada vdc
0237011004C20220337
1237011004C20220459
2237011004C20220563
3237011004C20220669
4237011004C20220775
\n", "
" ], "text/plain": [ " PDVDEPARA.Practico Código Ciclo vdc Quantidade Acumulada vdc\n", "0 23701 1004 C202203 37\n", "1 23701 1004 C202204 59\n", "2 23701 1004 C202205 63\n", "3 23701 1004 C202206 69\n", "4 23701 1004 C202207 75" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_vdc_agrupado = df_vdc.groupby(['PDVDEPARA.Practico',\t'Código','Ciclo'])['Quantidade Acumulada vdc'].max().reset_index()\n", "\n", "df_vdc_agrupado = df_vdc_agrupado.rename(columns={'Ciclo':'Ciclo vdc'})\n", "\n", "df_vdc_agrupado['PDVDEPARA.Practico'] = df_vdc_agrupado['PDVDEPARA.Practico'].fillna(0)\n", "\n", "df_vdc_agrupado.head()" ] }, { "cell_type": "code", "execution_count": 45, "id": "e01b2f8d", "metadata": {}, "outputs": [], "source": [ "df_vdc_agrupado = df_vdc_agrupado[df_vdc_agrupado['PDVDEPARA.Practico'] != 'nan']" ] }, { "cell_type": "code", "execution_count": 46, "id": "4861b401", "metadata": {}, "outputs": [], "source": [ "df_vdc_agrupado['PDVDEPARA.Practico'] = df_vdc_agrupado['PDVDEPARA.Practico'].astype('Int64')" ] }, { "cell_type": "code", "execution_count": 47, "id": "8ec14143", "metadata": {}, "outputs": [], "source": [ "df_final = pd.merge(left=df_final, right = df_vdc_agrupado, right_on=['Ciclo vdc','Código','PDVDEPARA.Practico'],left_on=['CICLO SIMILAR','PRODUTO SIMILAR','PDV'],how='left')\n", "\n", "df_final['Quantidade Acumulada vdc'] = df_final['Quantidade Acumulada vdc'].fillna(0)\n", "\n", "\n", "df_final['Vendas Ciclo Lançamento'] = np.where(df_final['Quantidade Acumulada vdc']>0, df_final['Quantidade Acumulada vdc'], df_final['Vendas Ciclo Lançamento'])\n", "\n", "df_final = df_final.drop(columns='Quantidade Acumulada vdc')\n", "\n", "\n", "df_final = df_final.drop(columns='Ciclo vdc')\n", "\n" ] }, { "cell_type": "code", "execution_count": 48, "id": "07f043f2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CANALUFmed_por_canal
0CDAL1.529412
1HIBAL0.294118
2HIBBA0.823529
3HIBBA30.000000
4HIBSE0.058824
5HIBVDC0.058824
6VDAL1.411765
7VDBA1.235294
8VDBA30.235294
9VDSE0.764706
10VDVDC1.000000
\n", "
" ], "text/plain": [ " CANAL UF med_por_canal\n", "0 CD AL 1.529412\n", "1 HIB AL 0.294118\n", "2 HIB BA 0.823529\n", "3 HIB BA3 0.000000\n", "4 HIB SE 0.058824\n", "5 HIB VDC 0.058824\n", "6 VD AL 1.411765\n", "7 VD BA 1.235294\n", "8 VD BA3 0.235294\n", "9 VD SE 0.764706\n", "10 VD VDC 1.000000" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "medi = df_final.groupby(['CANAL','UF'])['MEDIANA DO HISTÓRICO USADA'].max().reset_index()\n", "medi = medi.rename(columns={'MEDIANA DO HISTÓRICO USADA':'med_por_canal'})\n", "medi" ] }, { "cell_type": "code", "execution_count": 49, "id": "94abddce", "metadata": {}, "outputs": [], "source": [ "df_final = pd.merge(left=df_final, right=medi,on=['CANAL','UF'],how='inner')\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 50, "id": "27906593", "metadata": {}, "outputs": [], "source": [ "df_final['CRESCIMENTO_FINAL'] = df_final['CRESCIMENTO_GERAL'] + CRESCIMENTO #crescimento do pdv\n", "\n", "df_final['CRESCIMENTO_FINAL'] = np.where(df_final['CRESCIMENTO_GERAL'] + CRESCIMENTO>0.8,0.8,df_final['CRESCIMENTO_GERAL'] + CRESCIMENTO)\n", "\n", "df_final['CRESCIMENTO_FINAL'] = np.where(df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO']<0,0,df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO'])\n", "\n", "#df_final['MEDIANA DO HISTÓRICO USADA'] = np.where(df_final['MEDIANA DO HISTÓRICO']==0, df_final['med_por_canal'],df_final['MEDIANA DO HISTÓRICO'])\n" ] }, { "cell_type": "code", "execution_count": 51, "id": "5ba0586e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.int64(0)" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final['med_por_canal'].isna().sum()" ] }, { "cell_type": "code", "execution_count": 52, "id": "1a625e69", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(124, 92)" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "# Primeiro cálculo intermediário\n", "df_final['PV GINSENG'] = np.where(df_final['CRESCIMENTO_FINAL'] * df_final['Vendas Ciclo Lançamento'] + df_final['Vendas Ciclo Lançamento'] < df_final['MEDIANA DO HISTÓRICO USADA'],\n", " round(df_final['CRESCIMENTO_FINAL'] * df_final['MEDIANA DO HISTÓRICO USADA']+ df_final['MEDIANA DO HISTÓRICO USADA'],0), \n", " round(df_final['CRESCIMENTO_FINAL']*df_final['Vendas Ciclo Lançamento']+df_final['Vendas Ciclo Lançamento'],0))\n", "\n", "df_final['PV GINSENG'] = np.where(df_final['PV GINSENG'].isna(),df_final['med_por_canal'] ,df_final['PV GINSENG'])\n", "\n", "df_final.shape" ] }, { "cell_type": "code", "execution_count": 53, "id": "f7434149", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Desativação', 'Histórico de Vendas do Ciclo 202413',\n", " 'Histórico de Vendas do Ciclo 202414',\n", " 'Histórico de Vendas do Ciclo 202415',\n", " 'Histórico de Vendas do Ciclo 202416',\n", " 'Histórico de Vendas do Ciclo 202417',\n", " 'Histórico de Vendas do Ciclo 202501',\n", " 'Histórico de Vendas do Ciclo 202502',\n", " 'Histórico de Vendas do Ciclo 202503',\n", " 'Histórico de Vendas do Ciclo 202504',\n", " 'Histórico de Vendas do Ciclo 202505',\n", " 'Histórico de Vendas do Ciclo 202506',\n", " 'Histórico de Vendas do Ciclo 202507'],\n", " dtype='object')" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns[29:42]" ] }, { "cell_type": "code", "execution_count": 54, "id": "ad10c069", "metadata": {}, "outputs": [], "source": [ "df_final.drop(columns=df_final.columns[29:42],inplace=True)" ] }, { "cell_type": "code", "execution_count": 55, "id": "66772a9a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Histórico de Vendas do Ciclo 202508',\n", " 'Histórico de Vendas do Ciclo 202509',\n", " 'Histórico de Vendas do Ciclo 202510',\n", " 'Histórico de Vendas do Ciclo 202511',\n", " 'Histórico de Vendas do Ciclo 202512',\n", " 'Histórico de Vendas do Ciclo Atual'],\n", " dtype='object')" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns[29:35]" ] }, { "cell_type": "code", "execution_count": 56, "id": "15b7149f", "metadata": {}, "outputs": [], "source": [ "df_final = df_final.rename(columns={df_final.columns[30]: \"C-4\", df_final.columns[31]: \"C-3\",df_final.columns[32]: \"C-2\",df_final.columns[33]: \"C-1\",df_final.columns[34]:'VENDAS CICLO ATUAL'})\n" ] }, { "cell_type": "code", "execution_count": 57, "id": "f9bddbb1", "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', 'STATUS',\n", " 'ANALISTA EUD', 'Classe', 'SKU', 'Descrição', 'Subcategoria',\n", " 'Lançamento', 'Histórico de Vendas do Ciclo 202508', 'C-4', 'C-3',\n", " 'C-2', 'C-1', 'VENDAS CICLO ATUAL', 'Dias sem venda',\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", " 'Estoque em Transito', 'Pedido Pendente',\n", " 'Compra inteligente semanal/Sugestão de compra',\n", " 'Compra inteligente Próximo Ciclo',\n", " 'Compra inteligente Próximo Ciclo + 1', 'Item Desativado',\n", " 'Data Prevista Regularização', 'Carteira Bloqueada Para Novos Pedidos',\n", " 'Planograma', 'Quantidade por caixa', 'Preço Sell In', 'Quantidade',\n", " 'Item analisado', 'Histórico de Vendas do Ciclo 202513', 'match_x',\n", " 'CRESCIMENTO', 'Ciclo', 'INICIO CICLO', 'FIM CICLO', 'DURAÇÃO',\n", " 'match_y', 'dias_ate_inicio', 'INICIO CICLO SIMILAR',\n", " 'FIM CICLO SIMILAR', 'DURAÇÃO CICLO SIMILAR', 'Código do Produto',\n", " 'Ciclo', 'Vendas Ciclo Lançamento', 'CRESCIMENTO_GERAL',\n", " 'Pico Vendas Similar Ultimos 6 ciclos', 'MEDIANA DO HISTÓRICO',\n", " 'MEDIA DO HISTÓRICO', 'MEDIANA DO HISTÓRICO USADA',\n", " 'PDVDEPARA.Practico', 'Código', 'med_por_canal', 'CRESCIMENTO_FINAL',\n", " 'PV GINSENG'],\n", " dtype='object')" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns" ] }, { "cell_type": "code", "execution_count": 58, "id": "fe73c93e", "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',\n", " 'ANALISTA EUD', 'SKU', 'Descrição', 'Subcategoria', 'Lançamento',\n", " 'Histórico de Vendas do Ciclo 202508', 'C-4', 'C-3', 'C-2', 'C-1',\n", " 'VENDAS CICLO ATUAL', 'Dias sem venda', 'Projeção Próximo Ciclo',\n", " 'Projeção Próximo Ciclo + 1', 'Estoque Atual', 'Estoque em Transito',\n", " 'Pedido Pendente', 'Preço Sell In',\n", " 'Histórico de Vendas do Ciclo 202513', 'Código do Produto',\n", " 'Vendas Ciclo Lançamento', 'Pico Vendas Similar Ultimos 6 ciclos',\n", " 'MEDIANA DO HISTÓRICO', 'MEDIA DO HISTÓRICO',\n", " 'MEDIANA DO HISTÓRICO USADA', 'PV GINSENG'],\n", " dtype='object')" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "df_final.drop(columns=['match_x','match_y','STATUS', 'Classe','Promoção Próximo Ciclo', 'Promoção Próximo Ciclo + 1',\n", " 'Compra inteligente semanal/Sugestão de compra',\n", " 'Compra inteligente Próximo Ciclo',\n", " 'Compra inteligente Próximo Ciclo + 1', 'Item Desativado',\n", " 'Data Prevista Regularização', 'Carteira Bloqueada Para Novos Pedidos',\n", " 'Planograma', 'Quantidade por caixa','Quantidade',\n", " 'Item analisado', 'match_x', 'CRESCIMENTO', 'Ciclo', 'INICIO CICLO',\n", " 'FIM CICLO', 'DURAÇÃO', 'match_y', 'dias_ate_inicio',\n", " 'INICIO CICLO SIMILAR', 'FIM CICLO SIMILAR', 'DURAÇÃO CICLO SIMILAR','Ciclo',\n", " 'CRESCIMENTO_GERAL','PDVDEPARA.Practico', 'Código',\n", " 'med_por_canal', 'CRESCIMENTO_FINAL'],inplace=True)\n", "df_final.columns" ] }, { "cell_type": "code", "execution_count": 59, "id": "9333bc77", "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',\n", " 'ANALISTA EUD', 'SKU', 'DESCRIÇÃO', 'SUBCATEGORIA', 'LANÇAMENTO', 'C-4',\n", " 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL', 'DIAS SEM VENDA',\n", " 'PROJEÇÃO PRÓXIMO CICLO', 'PROJEÇÃO PRÓXIMO CICLO + 1', 'ESTOQUE ATUAL',\n", " 'ESTOQUE EM TRANSITO', 'PEDIDO PENDENTE', 'PREÇO SELL IN',\n", " 'CÓDIGO DO PRODUTO', 'VENDAS CICLO LANÇAMENTO',\n", " 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS', 'MEDIANA DO HISTÓRICO',\n", " 'MEDIA DO HISTÓRICO', 'MEDIANA DO HISTÓRICO USADA', 'PV GINSENG'],\n", " dtype='object')" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns = df_final.columns.str.upper()\n", "\n", "df_final.drop(columns=df_final.filter(regex='HISTÓRICO DE VENDAS DO CICLO').columns, inplace=True)\n", "\n", "df_final.columns" ] }, { "cell_type": "code", "execution_count": 60, "id": "5abd4bae", "metadata": {}, "outputs": [], "source": [ "df_final = df_final.drop(columns=['DESCRIÇÃO','MEDIANA DO HISTÓRICO'])" ] }, { "cell_type": "code", "execution_count": 61, "id": "62ce5c62", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(124, 44)" ] }, "execution_count": 61, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.shape" ] }, { "cell_type": "code", "execution_count": 62, "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',\n", " 'ANALISTA EUD', 'SKU', 'SUBCATEGORIA', 'LANÇAMENTO', 'C-4', 'C-3',\n", " 'C-2', 'C-1', 'VENDAS CICLO ATUAL', 'DIAS SEM VENDA',\n", " 'PROJEÇÃO PRÓXIMO CICLO', 'PROJEÇÃO PRÓXIMO CICLO + 1', 'ESTOQUE ATUAL',\n", " 'ESTOQUE EM TRANSITO', 'PEDIDO PENDENTE', 'PREÇO SELL IN',\n", " 'CÓDIGO DO PRODUTO', 'VENDAS CICLO LANÇAMENTO',\n", " 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS', 'MEDIA DO HISTÓRICO',\n", " 'MEDIANA DO HISTÓRICO USADA', 'PV GINSENG'],\n", " dtype='object')" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_final.columns" ] }, { "cell_type": "code", "execution_count": 63, "id": "25cbff26", "metadata": {}, "outputs": [], "source": [ "df_final = df_final.reindex(columns=[\n", " 'SUPERVISOR',\n", " 'CANAL',\n", " 'UF',\n", " 'PDV',\n", " 'PDV DESC',\n", " 'PRODUTO LANÇAMENTO',\n", " 'DESCRIÇÃO DO LANÇAMENTO',\n", " 'MARCA',\n", " 'CATEGORIA',\n", " 'MECANICA CONSUMIDOR',\n", " '% CONSUMIDOR',\n", " 'MECANICA REVENDEDOR',\n", " '% REVENDEDOR',\n", " 'TIPO DE PRODUTO',\n", " 'IAF',\n", " 'FOCO',\n", " 'PRODUTO SIMILAR',\n", " 'DESCRIÇÃO SIMILAR',\n", " 'CICLO SIMILAR',\n", " 'VENDAS CICLO LANÇAMENTO',\n", " 'C-4',\n", " 'C-3',\n", " 'C-2',\n", " 'C-1',\n", " 'VENDAS CICLO ATUAL',\n", " 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n", " 'PV GINSENG',\n", " 'PROJEÇÃO PRÓXIMO CICLO',\n", " 'PROJEÇÃO PRÓXIMO CICLO + 1',\n", " ])\n" ] }, { "cell_type": "code", "execution_count": 64, "id": "a3e80cb4", "metadata": {}, "outputs": [], "source": [ "df_final['SUGESTÃO METASELLIN'] = ''\n", "df_final['SUGESTÃO ABASTECIMENTO'] = ''\n", "df_final['SUGESTÃO COMERCIAL'] = ''\n" ] }, { "cell_type": "code", "execution_count": 65, "id": "aa11b320", "metadata": {}, "outputs": [], "source": [ "df_final['PV GINSENG'] = np.ceil(df_final['PV GINSENG'])" ] }, { "cell_type": "code", "execution_count": 66, "id": "2df3e2e9", "metadata": {}, "outputs": [], "source": [ "df_final.to_excel(r'C:\\Users\\joao.herculano\\Documents\\lançamentoQDB14-10.xlsx',index=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "391a0e3c", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 5 }