diff --git a/Lançamentos/Script_lançamento_boti_v2.ipynb b/Lançamentos/Script_lançamento_boti_v2.ipynb index 49623c8..5b72a9d 100644 --- a/Lançamentos/Script_lançamento_boti_v2.ipynb +++ b/Lançamentos/Script_lançamento_boti_v2.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 6, + "execution_count": 1, "id": "6ad35669", "metadata": {}, "outputs": [], @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 2, "id": "fa16d50c", "metadata": {}, "outputs": [], @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 3, "id": "9fcdc77a", "metadata": {}, "outputs": [], @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 4, "id": "bbec229d", "metadata": {}, "outputs": [ @@ -99,17 +99,17 @@ " \n", " \n", " \n", - " 2241\n", - " C202511\n", - " 2025-07-21\n", - " 2025-08-10\n", + " 2283\n", + " C202512\n", + " 2025-08-11\n", + " 2025-08-31\n", " 21\n", " BOTICARIO\n", - " 2025-07-21\n", - " 11\n", + " 2025-08-11\n", + " 12\n", " C2025\n", - " C202514\n", - " 49\n", + " C202515\n", + " 55\n", " 1\n", " \n", " \n", @@ -118,13 +118,13 @@ ], "text/plain": [ " Ciclo INICIO CICLO FIM CICLO DURAÇÃO MARCA Date \\\n", - "2241 C202511 2025-07-21 2025-08-10 21 BOTICARIO 2025-07-21 \n", + "2283 C202512 2025-08-11 2025-08-31 21 BOTICARIO 2025-08-11 \n", "\n", " NUM_CICLO ANO_CICLO CICLOMAIS2 dias_ate_inicio match \n", - "2241 11 C2025 C202514 49 1 " + "2283 12 C2025 C202515 55 1 " ] }, - "execution_count": 9, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -135,12 +135,43 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 5, + "id": "0245ed28", + "metadata": {}, + "outputs": [], + "source": [ + "ciclo_lanc = filtered_calendario['Ciclo'].max()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "7a3c1e6f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'C202512'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ciclo_lanc" + ] + }, + { + "cell_type": "code", + "execution_count": 7, "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\\BOT\\BOT - C11\\arquivos para geração da sugestão\\SIMILARES\\PRODUTOS SIMILARES - BOT.xlsx\")\n", + "df_similares = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BOT\\BOT - C12\\LANÇAMENTOS\\arquivos para geração da sugestão\\SIMILARES\\PRODUTOS SIMILARES - BOT.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", @@ -157,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "id": "99ea95e6", "metadata": {}, "outputs": [ @@ -171,7 +202,7 @@ " dtype='object')" ] }, - "execution_count": 11, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -182,12 +213,12 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "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\\BOT\\BOT - C11\\arquivos para geração da sugestão\\TABELA DE PEDIDO\\Pedidos Semanais Especiais - BOT - 202511.xlsx\")\n", + "df_tabela = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BOT\\BOT - C12\\LANÇAMENTOS\\arquivos para geração da sugestão\\TABELA DE PEDIDO\\Pedidos Semanais Especiais - BOT - 202512.xlsx\")\n", "\n", "df_tabela = df_tabela[df_tabela['Região'] == 'NNE'] \n", "\n", @@ -200,29 +231,37 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 10, + "id": "e0c55962", + "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\")" + ] + }, + { + "cell_type": "code", + "execution_count": 11, "id": "a3a045d9", "metadata": {}, "outputs": [], "source": [ - "df_pdv = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BASE DE DADOS LANÇAMENTO\\BOT\\PDV\\PDV_ATT.xlsx\")\n", "\n", - "df_pdv_origi = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BASE DE DADOS LANÇAMENTO\\BOT\\PDV\\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['PDV'] = df_pdv['PDV DESC'].str.split(\"-\").str[0].str.strip()\n", - "\n", "df_pdv['UF'] = np.where(df_pdv['UF'] == 'VDC','BA',df_pdv['UF'])\n", "\n", "#ignorando a PDV que ainda não está online\n", "df_pdv = df_pdv[df_pdv['DESCRIÇÃO PDV'] != '23813-COMERCIO-HIB VALENTE']\n", "\n", - "df_pdv = df_pdv[df_pdv['status'] != \"INATIVO\"]\n", + "df_pdv = df_pdv[df_pdv['STATUS'] != \"INATIVO\"]\n", "\n", - "df_pdv = df_pdv[df_pdv['status'] != \"MATRIZ\"]\n", + "df_pdv = df_pdv[df_pdv['STATUS'] != \"MATRIZ\"]\n", "\n", "df_pdv = df_pdv[df_pdv['SUPERVISOR'] != 'Inativa']\n", "\n", @@ -231,30 +270,7 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "849d5297", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Index(['PDV', 'CANAL', 'DESCRIÇÃO PDV', 'PDV DESC', 'UF', 'ANALISTA',\n", - " 'SUPERVISOR', 'status', 'MATCH'],\n", - " dtype='object')" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_pdv.columns" - ] - }, - { - "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "id": "df04a501", "metadata": {}, "outputs": [], @@ -266,7 +282,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "id": "0da911af", "metadata": {}, "outputs": [ @@ -274,17 +290,17 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_26024\\1835738500.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_37548\\2509858446.py:10: DtypeWarning: Columns (6,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" ] }, { "data": { "text/plain": [ - "(114430, 47)" + "(130656, 47)" ] }, - "execution_count": 16, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -293,7 +309,7 @@ "# 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\\BOT\\BOT - C11\\atualização\\DRAFT_\" # arquivo dos drafts\n", + "folder_path = r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BOT\\BOT - C12\\LANÇAMENTOS\\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", @@ -308,7 +324,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 14, "id": "0c8c7493", "metadata": {}, "outputs": [], @@ -318,15 +334,14 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 15, "id": "91298cde", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "Index(['Histórico de Vendas do Ciclo 202408',\n", - " 'Histórico de Vendas do Ciclo 202409',\n", + "Index(['Histórico de Vendas do Ciclo 202409',\n", " 'Histórico de Vendas do Ciclo 202410',\n", " 'Histórico de Vendas do Ciclo 202411',\n", " 'Histórico de Vendas do Ciclo 202412',\n", @@ -342,11 +357,12 @@ " '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 Atual'],\n", " dtype='object')" ] }, - "execution_count": 18, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -357,7 +373,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 16, "id": "34e179cb", "metadata": {}, "outputs": [ @@ -365,7 +381,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_26024\\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_37548\\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" ] } @@ -402,7 +418,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 17, "id": "4bc8c2b4", "metadata": {}, "outputs": [], @@ -414,30 +430,29 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 18, "id": "c1451562", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(5459, 14)" + "(17025, 14)" ] }, - "execution_count": 21, + "execution_count": 18, "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\\BOT\\BOT - C11\\arquivos para geração da sugestão\\VENDAS_DIARIAS\\FormFiltroConsultaVendaSintetica_22_05_2025_16_26_17.xls\")\n", - "\n", + "df_venda_diaria = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BOT\\BOT - C12\\LANÇAMENTOS\\arquivos para geração da sugestão\\VENDAS_DIARIAS\\FormFiltroConsultaVendaSintetica_17_06_2025_14_04_40.xls\")\n", "df_venda_diaria.shape" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 19, "id": "882e68aa", "metadata": {}, "outputs": [ @@ -451,7 +466,7 @@ " dtype='object')" ] }, - "execution_count": 22, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -462,17 +477,17 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 20, "id": "c7ddaf20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(5459, 16)" + "(17025, 16)" ] }, - "execution_count": 23, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -491,17 +506,17 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 21, "id": "7119556a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(5459, 17)" + "(17025, 17)" ] }, - "execution_count": 24, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } @@ -525,7 +540,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 22, "id": "c707a1b6", "metadata": {}, "outputs": [ @@ -560,37 +575,37 @@ " \n", " 0\n", " 12522\n", - " 48617\n", - " C202210\n", + " 4522\n", + " C202312\n", " 1\n", " \n", " \n", " 1\n", " 12522\n", - " 48617\n", - " C202211\n", + " 4522\n", + " C202314\n", " 2\n", " \n", " \n", " 2\n", " 12522\n", - " 48617\n", - " C202212\n", - " 5\n", + " 4522\n", + " C202406\n", + " 3\n", " \n", " \n", " 3\n", " 12522\n", - " 48617\n", - " C202213\n", - " 7\n", + " 4522\n", + " C202407\n", + " 4\n", " \n", " \n", " 4\n", " 12522\n", - " 48617\n", - " C202214\n", - " 8\n", + " 4522\n", + " C202410\n", + " 5\n", " \n", " \n", " ...\n", @@ -600,60 +615,170 @@ " ...\n", " \n", " \n", - " 1398\n", + " 5800\n", " 5699\n", - " 86825\n", - " C202410\n", - " 1\n", + " 81054\n", + " C202503\n", + " 167\n", " \n", " \n", - " 1399\n", + " 5801\n", " 5699\n", - " 86825\n", - " C202411\n", - " 2\n", + " 81054\n", + " C202504\n", + " 168\n", " \n", " \n", - " 1400\n", + " 5802\n", " 5699\n", - " 86825\n", - " C202412\n", - " 3\n", + " 81054\n", + " C202505\n", + " 169\n", " \n", " \n", - " 1401\n", + " 5803\n", " 5699\n", - " 86825\n", - " C202415\n", - " 4\n", + " 81054\n", + " C202506\n", + " 170\n", " \n", " \n", - " 1402\n", + " 5804\n", " 5699\n", - " 86825\n", - " C202417\n", + " 85293\n", + " C202506\n", " 5\n", " \n", " \n", "\n", - "

1403 rows × 4 columns

\n", + "

5805 rows × 4 columns

\n", "" ], "text/plain": [ " PDV Código do Produto Ciclo Quantidade Acumulada\n", - "0 12522 48617 C202210 1\n", - "1 12522 48617 C202211 2\n", - "2 12522 48617 C202212 5\n", - "3 12522 48617 C202213 7\n", - "4 12522 48617 C202214 8\n", + "0 12522 4522 C202312 1\n", + "1 12522 4522 C202314 2\n", + "2 12522 4522 C202406 3\n", + "3 12522 4522 C202407 4\n", + "4 12522 4522 C202410 5\n", "... ... ... ... ...\n", - "1398 5699 86825 C202410 1\n", - "1399 5699 86825 C202411 2\n", - "1400 5699 86825 C202412 3\n", - "1401 5699 86825 C202415 4\n", - "1402 5699 86825 C202417 5\n", + "5800 5699 81054 C202503 167\n", + "5801 5699 81054 C202504 168\n", + "5802 5699 81054 C202505 169\n", + "5803 5699 81054 C202506 170\n", + "5804 5699 85293 C202506 5\n", "\n", - "[1403 rows x 4 columns]" + "[5805 rows x 4 columns]" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_venda_diaria = df_venda_diaria.drop_duplicates()\n", + "\n", + "df_venda_agrupado = df_venda_diaria.fillna(0).groupby(['PDV', 'Código do Produto','Ciclo'])['Quantidade Acumulada'].max().reset_index()\n", + "df_venda_agrupado" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "083ff829", + "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", + "
PDVCódigo do ProdutoCicloQuantidade Acumulada
29552099481054C20221335
\n", + "
" + ], + "text/plain": [ + " PDV Código do Produto Ciclo Quantidade Acumulada\n", + "2955 20994 81054 C202213 35" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_venda_agrupado[(df_venda_agrupado['Ciclo']=='C202213')&(df_venda_agrupado['Código do Produto']==81054)&(df_venda_agrupado['PDV']=='20994')]" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "59707396", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Ciclo object\n", + "Código do Produto int64\n", + "PDV object\n", + "dtype: object" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_venda_agrupado[['Ciclo','Código do Produto','PDV']].dtypes" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "bdf6abbb", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "CICLO SIMILAR object\n", + "PRODUTO SIMILAR float64\n", + "PDV Int64\n", + "dtype: object" ] }, "execution_count": 25, @@ -662,10 +787,7 @@ } ], "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" + "df_final[['CICLO SIMILAR','PRODUTO SIMILAR','PDV']].dtypes" ] }, { @@ -677,7 +799,7 @@ { "data": { "text/plain": [ - "(816, 75)" + "(1216, 76)" ] }, "execution_count": 26, @@ -731,7 +853,7 @@ "metadata": {}, "outputs": [], "source": [ - "df_final['PRODUTO LANÇAMENTO'] = df_final['PRODUTO LANÇAMENTO'].astype('Int64')\n", + "df_final['PRODUTO SIMILAR'] = df_final['PRODUTO SIMILAR'].astype('Int64')\n", "\n", "df_venda_agrupado['PDV'] = df_venda_agrupado['PDV'].astype('Int64')\n", "\n", @@ -743,16 +865,48 @@ { "cell_type": "code", "execution_count": 31, + "id": "aea3e9a8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "np.float64(3757.0)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_final['Vendas Ciclo Lançamento'].sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "bde12ed6", + "metadata": {}, + "outputs": [], + "source": [ + "df_final = df_final[df_final['PRODUTO LANÇAMENTO'].notna()]\n", + "df_final['Vendas Ciclo Lançamento'] = df_final['Vendas Ciclo Lançamento'].fillna(0)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 33, "id": "69c88d20", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "np.int64(12)" + "np.int64(14)" ] }, - "execution_count": 31, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -763,15 +917,14 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 34, "id": "f5206f50", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "Index(['Histórico de Vendas do Ciclo 202408',\n", - " 'Histórico de Vendas do Ciclo 202409',\n", + "Index(['Desativação', 'Histórico de Vendas do Ciclo 202409',\n", " 'Histórico de Vendas do Ciclo 202410',\n", " 'Histórico de Vendas do Ciclo 202411',\n", " 'Histórico de Vendas do Ciclo 202412',\n", @@ -790,7 +943,7 @@ " dtype='object')" ] }, - "execution_count": 32, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -801,17 +954,99 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 35, + "id": "5e33d293", + "metadata": {}, + "outputs": [], + "source": [ + "df_jacobina = pd.read_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\REGIÃO JACOBINA\\draft unificado.xlsx\")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "id": "4d23ff5a", + "metadata": {}, + "outputs": [], + "source": [ + "df_jacobina = df_jacobina[['PDV', 'SKU','202408', '202409',\n", + " '202410', '202411', '202412', '202413', '202414', '202415', '202416',\n", + " '202417', '202501', '202502', '202503', '202504', '202505', '202506',\n", + " '202507']]" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "5adc5831", + "metadata": {}, + "outputs": [], + "source": [ + "ciclos = [\n", + " '202408', '202409', '202410', '202411', '202412', '202413',\n", + " '202414', '202415', '202416', '202417', '202501', '202502',\n", + " '202503', '202504', '202505', '202506', '202507']\n", + "\n", + "df_jacobina[ciclos] = df_jacobina[ciclos].fillna(0)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "1c4f5d9d", + "metadata": {}, + "outputs": [], + "source": [ + "df_final = pd.merge(left=df_final,right=df_jacobina,left_on=['PRODUTO SIMILAR','PDV'],right_on=['SKU','PDV'],how='left')" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "2529e624", + "metadata": {}, + "outputs": [], + "source": [ + "# Gera pares de colunas: coluna estática ↔ coluna de histórico\n", + "pares_validos = [\n", + " (ciclo, f'Histórico de Vendas do Ciclo {ciclo}')\n", + " for ciclo in ciclos\n", + " if ciclo in df_final.columns and f'Histórico de Vendas do Ciclo {ciclo}' in df_final.columns\n", + "]\n", + "\n", + "# Separa os nomes das colunas\n", + "colunas_estaticas = [c[0] for c in pares_validos]\n", + "colunas_historico = [c[1] for c in pares_validos]\n", + "\n", + "# Aplica a regra: se valor na coluna estática for maior, sobrescreve no histórico\n", + "for col_estatica, col_hist in zip(colunas_estaticas, colunas_historico):\n", + " df_final[col_hist] = df_final[col_estatica].where(\n", + " df_final[col_estatica] > df_final[col_hist],\n", + " df_final[col_hist]\n", + " )\n" + ] + }, + { + "cell_type": "code", + "execution_count": 40, "id": "0a1bb832", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_37548\\1328364976.py:8: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n", + " variacao_mensal = soma_mensal.pct_change()\n" + ] + }, { "data": { "text/plain": [ - "np.float64(0.3797)" + "np.float64(0.1817)" ] }, - "execution_count": 33, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -852,7 +1087,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 41, "id": "a9647c32", "metadata": {}, "outputs": [], @@ -865,7 +1100,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 42, "id": "b107e519", "metadata": {}, "outputs": [ @@ -878,11 +1113,11 @@ " '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 Atual'],\n", + " 'Histórico de Vendas do Ciclo 202508'],\n", " dtype='object')" ] }, - "execution_count": 35, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -893,7 +1128,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 43, "id": "8290853c", "metadata": {}, "outputs": [], @@ -902,15 +1137,48 @@ "\n", "df_final['Pico Vendas Similar Ultimos 6 ciclos'] = df_final[VENDA_SIMILAR_6_MESES].max(axis=1)\n", "\n", + "df_final['Pico Vendas Similar Ultimos 6 ciclos'] = df_final['Pico Vendas Similar Ultimos 6 ciclos'].fillna(0)\n", "\n", - "df_final['MEDIANA DO HISTÓRICO'] = df_final[colunas_mensais].dropna().median(axis=1)\n", + "df_final['MEDIANA DO HISTÓRICO'] = df_final[colunas_mensais].median(axis=1, skipna=True)\n", "\n", - "df_final['Vendas Ciclo Lançamento'] = df_final['Vendas Ciclo Lançamento'].fillna(0)" + "\n" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 44, + "id": "d8b30560", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0 1.0\n", + "1 3.5\n", + "2 0.5\n", + "3 0.0\n", + "4 1.0\n", + " ... \n", + "1059 0.0\n", + "1060 0.0\n", + "1061 0.0\n", + "1062 0.0\n", + "1063 0.0\n", + "Length: 1064, dtype: object" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_final[colunas_mensais].median(axis=1, skipna=True)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 45, "id": "07f043f2", "metadata": {}, "outputs": [ @@ -943,36 +1211,36 @@ " \n", " 0\n", " CD\n", - " 44.0\n", + " 20.0\n", " \n", " \n", " 1\n", " HIB\n", - " 9.0\n", + " 2.0\n", " \n", " \n", " 2\n", " LJ\n", - " 11.0\n", + " 3.5\n", " \n", " \n", " 3\n", " VD\n", - " 28.0\n", + " 10.0\n", " \n", " \n", "\n", "" ], "text/plain": [ - " CANAL med_por_canal\n", - "0 CD 44.0\n", - "1 HIB 9.0\n", - "2 LJ 11.0\n", - "3 VD 28.0" + " CANAL med_por_canal\n", + "0 CD 20.0\n", + "1 HIB 2.0\n", + "2 LJ 3.5\n", + "3 VD 10.0" ] }, - "execution_count": 37, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -985,7 +1253,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 46, "id": "94abddce", "metadata": {}, "outputs": [], @@ -995,7 +1263,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 47, "id": "09cc2f82", "metadata": {}, "outputs": [], @@ -1022,7 +1290,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 48, "id": "5a827c08", "metadata": {}, "outputs": [ @@ -1102,7 +1370,7 @@ "4 23701 48617 C202216 22" ] }, - "execution_count": 40, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1120,7 +1388,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 49, "id": "8ec14143", "metadata": {}, "outputs": [], @@ -1130,7 +1398,7 @@ "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", + "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", @@ -1141,186 +1409,140 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 50, "id": "1a625e69", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_37548\\2817892533.py:10: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n", + " df_final['MEDIANA DO HISTÓRICO'] = df_final['MEDIANA DO HISTÓRICO'].fillna(0)\n", + "C:\\Users\\joao.herculano\\AppData\\Local\\Temp\\ipykernel_37548\\2817892533.py:19: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`\n", + " df_final['MEDIANA DO HISTÓRICO'] = df_final['MEDIANA DO HISTÓRICO'].fillna(0)\n" + ] + }, { "data": { "text/plain": [ - "(816, 89)" + "(1022, 108)" ] }, - "execution_count": 43, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "df_final['CRESCIMENTO_FINAL'] = df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO'] #crescimento do pdv\n", "\n", - "df_final['CRESCIMENTO_FINAL'] = np.where(df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO']>0.8,0.8,df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO'])\n", + "# Cálculo do crescimento\n", + "crescimento_final = df_final['CRESCIMENTO_GERAL'] + df_final['CRESCIMENTO']\n", + "crescimento_final = crescimento_final.clip(lower=0.2, upper=0.8) # limita entre 0 e 0.8\n", + "df_final['CRESCIMENTO_FINAL'] = crescimento_final\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", + "df_final['CRESCIMENTO_FINAL'] = np.where(df_final['CRESCIMENTO_FINAL'].isna(),df_final['CRESCIMENTO_GERAL'],df_final['CRESCIMENTO_FINAL'])\n", "\n", - "df_final['MEDIANA DO HISTÓRICO'] = np.where(df_final['MEDIANA DO HISTÓRICO']==0, df_final['med_por_canal'],df_final['MEDIANA DO HISTÓRICO'])\n", + "df_final['CRESCIMENTO_FINAL'] = df_final['CRESCIMENTO_FINAL'].fillna(0)\n", "\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'],\n", - " round(df_final['CRESCIMENTO_FINAL'] * df_final['MEDIANA DO HISTÓRICO']+ df_final['MEDIANA DO HISTÓRICO'],0), \n", - " round(df_final['CRESCIMENTO_FINAL']*df_final['Vendas Ciclo Lançamento']+df_final['Vendas Ciclo Lançamento'],0))\n", + "df_final['MEDIANA DO HISTÓRICO'] = df_final['MEDIANA DO HISTÓRICO'].fillna(0)\n", "\n", - "df_final['PV GINSENG'] = np.where(df_final['PV GINSENG'].isna(),df_final['med_por_canal'] ,df_final['PV GINSENG'])\n", + "# Corrige mediana do histórico onde for zero\n", + "df_final['MEDIANA DO HISTÓRICO'] = np.where(\n", + " df_final['MEDIANA DO HISTÓRICO'] == 0,\n", + " df_final['med_por_canal'],\n", + " df_final['MEDIANA DO HISTÓRICO']\n", + ")\n", "\n", - "df_final.shape" + "df_final['MEDIANA DO HISTÓRICO'] = df_final['MEDIANA DO HISTÓRICO'].fillna(0)\n", + "\n", + "\n", + "\n", + "# Cálculo do PV GINSENG\n", + "pv_crescimento = (df_final['CRESCIMENTO_FINAL']+1) * df_final['Vendas Ciclo Lançamento']\n", + "pv_mediana = (df_final['CRESCIMENTO_FINAL'] + 1) * df_final['MEDIANA DO HISTÓRICO']\n", + "\n", + "df_final['PV GINSENG'] = np.where(\n", + " pv_crescimento < df_final['MEDIANA DO HISTÓRICO'],\n", + " pv_mediana.round(0),\n", + " pv_crescimento.round(0)\n", + ")\n", + "\n", + "# Se PV GINSENG for NA, substitui pela média por canal\n", + "df_final['PV GINSENG'] = df_final['PV GINSENG'].fillna(df_final['med_por_canal'].round(0))\n", + "\n", + "df_final['PV GINSENG'] = df_final['PV GINSENG'].round(0).astype(int)\n", + "\n", + "df_final.shape\n" ] }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 51, + "id": "cfdae71d", + "metadata": {}, + "outputs": [], + "source": [ + "df_final.to_excel(r\"C:\\Users\\joao.herculano\\GRUPO GINSENG\\Assistência Suprimentos - 2025\\SUPRIMENTOS\\BD_LANÇAMENTOS\\BOT\\BOT - C12\\LANÇAMENTOS\\validação.xlsx\",index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "7b058db6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Index(['Histórico de Vendas do Ciclo 202409',\n", + " 'Histórico de Vendas do Ciclo 202410',\n", + " 'Histórico de Vendas do Ciclo 202411',\n", + " 'Histórico de Vendas do Ciclo 202412',\n", + " '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", + " dtype='object')" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_final.columns[30:43]" + ] + }, + { + "cell_type": "code", + "execution_count": 53, "id": "ad10c069", "metadata": {}, "outputs": [], "source": [ - "df_final.drop(columns=df_final.columns[29:42],inplace=True)" + "df_final.drop(columns=df_final.columns[30:43],inplace=True)" ] }, { "cell_type": "code", - "execution_count": 45, - "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", - " 'Classe', 'SKU', 'Descrição', 'Subcategoria', 'Lançamento',\n", - " 'Desativação', '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 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 202407', '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", - " 'med_por_canal', 'PDVDEPARA.Practico', 'Código', 'CRESCIMENTO_FINAL',\n", - " 'PV GINSENG'],\n", - " dtype='object')" - ] - }, - "execution_count": 45, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_final.columns" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "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", - " 'Descrição', '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 Atual',\n", - " 'Histórico de Vendas do Ciclo 202407', 'Vendas Ciclo Lançamento',\n", - " 'Pico Vendas Similar Ultimos 6 ciclos', 'MEDIANA DO HISTÓRICO',\n", - " 'PDVDEPARA.Practico', 'Código', 'PV GINSENG'],\n", - " dtype='object')" - ] - }, - "execution_count": 46, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "\n", - "df_final.drop(columns=['status', 'Classe', 'SKU', 'Subcategoria', 'Lançamento',\n", - " 'Desativação','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', 'match_x',\n", - " 'CRESCIMENTO', 'Ciclo', 'INICIO CICLO', 'FIM CICLO', 'DURAÇÃO',\n", - " 'match_y', 'dias_ate_inicio', 'INICIO CICLO SIMILAR','med_por_canal', 'CRESCIMENTO_FINAL',\n", - " 'FIM CICLO SIMILAR', 'DURAÇÃO CICLO SIMILAR', 'Código do Produto','CRESCIMENTO_GERAL'],inplace=True)\n", - "df_final.columns" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "id": "66772a9a", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Index(['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 Atual'],\n", - " dtype='object')" - ] - }, - "execution_count": 47, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df_final.columns[23:28]" - ] - }, - { - "cell_type": "code", - "execution_count": 48, + "execution_count": 54, "id": "15b7149f", "metadata": {}, "outputs": [], "source": [ - "df_final = df_final.rename(columns={df_final.columns[23]: \"C-4\", df_final.columns[24]: \"C-3\",df_final.columns[25]: \"C-2\",df_final.columns[26]: \"C-1\",df_final.columns[27]:'VENDAS CICLO ATUAL'})\n" + "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": 49, + "execution_count": 55, "id": "9333bc77", "metadata": {}, "outputs": [ @@ -1330,15 +1552,32 @@ "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", - " 'DESCRIÇÃO', 'C-4', 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL',\n", - " 'VENDAS CICLO LANÇAMENTO', 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS',\n", - " 'MEDIANA DO HISTÓRICO', 'PDVDEPARA.PRACTICO', 'CÓDIGO', 'PV GINSENG'],\n", + " 'MECANICA REVENDEDOR', 'TIPO DE PRODUTO', 'MATCH', 'PDV',\n", + " 'PDV COMO TEXTO', 'CANAL', 'DESCRIÇÃO PDV', 'PDV DESC', 'UF',\n", + " 'ANALISTA', 'SUPERVISOR', 'STATUS', 'CLASSE', 'SKU_X', 'DESCRIÇÃO',\n", + " 'SUBCATEGORIA', 'LANÇAMENTO', 'DESATIVAÇÃO', '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', 'PROMOÇÃO PRÓXIMO CICLO',\n", + " 'PROMOÇÃO PRÓXIMO CICLO + 1', 'ESTOQUE ATUAL', 'ESTOQUE EM TRANSITO',\n", + " 'PEDIDO PENDENTE', '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', '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',\n", + " 'CÓDIGO DO PRODUTO', 'CICLO', 'VENDAS CICLO LANÇAMENTO', 'SKU_Y',\n", + " '202408', '202409', '202410', '202411', '202412', '202413', '202414',\n", + " '202415', '202416', '202417', '202501', '202502', '202503', '202504',\n", + " '202505', '202506', '202507', 'CRESCIMENTO_GERAL',\n", + " 'PICO VENDAS SIMILAR ULTIMOS 6 CICLOS', 'MEDIANA DO HISTÓRICO',\n", + " 'MED_POR_CANAL', 'PDVDEPARA.PRACTICO', 'CÓDIGO', 'CRESCIMENTO_FINAL',\n", + " 'PV GINSENG'],\n", " dtype='object')" ] }, - "execution_count": 49, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -1353,27 +1592,17 @@ }, { "cell_type": "code", - "execution_count": 50, - "id": "5abd4bae", - "metadata": {}, - "outputs": [], - "source": [ - "df_final = df_final.drop(columns=['DESCRIÇÃO','MEDIANA DO HISTÓRICO'])" - ] - }, - { - "cell_type": "code", - "execution_count": 51, + "execution_count": 56, "id": "62ce5c62", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(816, 32)" + "(1022, 94)" ] }, - "execution_count": 51, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -1384,18 +1613,106 @@ }, { "cell_type": "code", - "execution_count": 52, - "id": "25cbff26", + "execution_count": 57, + "id": "cecca116", "metadata": {}, "outputs": [], "source": [ - "df_final = df_final.reindex(columns=[\n", + "df_final[['C-4', 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL']] = df_final[['C-4', 'C-3', 'C-2', 'C-1', 'VENDAS CICLO ATUAL']].fillna(0)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "733e6e45", + "metadata": {}, + "outputs": [], + "source": [ + "df_final = df_final[[\n", " 'SUPERVISOR',\n", - " 'ANALISTA',\n", + " 'ANALISTA', \n", " 'CANAL',\n", " 'UF',\n", " 'PDV',\n", - " 'PDV DESC',\n", + " 'DESCRIÇÃO PDV',\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", + "]]" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "2e3a04cd", + "metadata": {}, + "outputs": [], + "source": [ + "df_final = df_final[[\n", + " 'SUPERVISOR',\n", + " 'ANALISTA', \n", + " 'CANAL',\n", + " 'UF',\n", + " 'PDV',\n", + " 'DESCRIÇÃO PDV',\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", + "]]" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "25cbff26", + "metadata": {}, + "outputs": [], + "source": [ + "df_final = df_final.reindex(columns=[\n", + " 'SUPERVISOR',\n", + " 'ANALISTA',\n", + " 'CANAL',\n", + " 'UF',\n", + " 'PDV',\n", + " 'DESCRIÇÃO PDV',\n", " 'PRODUTO LANÇAMENTO',\n", " 'DESCRIÇÃO DO LANÇAMENTO',\n", " 'MARCA',\n", @@ -1407,7 +1724,6 @@ " 'TIPO DE PRODUTO',\n", " 'IAF',\n", " 'FOCO',\n", - " 'SKU',\n", " 'PRODUTO SIMILAR',\n", " 'DESCRIÇÃO SIMILAR',\n", " 'CICLO SIMILAR',\n", @@ -1423,7 +1739,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 61, "id": "a3e80cb4", "metadata": {}, "outputs": [], @@ -1435,12 +1751,12 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 62, "id": "2df3e2e9", "metadata": {}, "outputs": [], "source": [ - "df_final.to_excel(f'C:/Users/joao.herculano/Documents/sugest{hoje}.xlsx',index=False)" + "df_final.to_excel(f'C:/Users/joao.herculano/Documents/Lançamento{hoje}{ciclo_lanc}.xlsx',index=False)" ] } ],