1
Well, I have this code, I want it to take specific columns of 3 sheets and join in one, ams is giving the following error: index 5 is out of Bounds for Axis 0 with size 1
import pandas as pd
Corp = pd.read_excel('C:/Users/t718787/Desktop/fotos/dbm.xlsx', 'Corp', usecols =['Num_CNPJ','Segmento','Cliente','Grupo','Regional','Gestor_Senior','Gerente','Lista_Distribuicao'])
Scib = pd.read_excel('C:/Users/t718787/Desktop/fotos/dbm.xlsx', 'SCIB', usecols =['Num_CNPJ','Segmento','Cliente','Grupo','Regional','Gestor_Senior','Gerente','Lista_Distribuicao'])
Gi = pd.read_excel('C:/Users/t718787/Desktop/fotos/dbm.xlsx', 'GI', usecols =['Num_CNPJ','Segmento','Cliente','Grupo','Regional','Gestor_Senior','Gerente','Lista_Distribuicao'])
Univ = pd.read_excel('C:/Users/t718787/Desktop/fotos/dbm.xlsx', 'Univ', usecols =['Num_CNPJ','Segmento','Cliente','Grupo','Regional','Gestor_Senior','Gerente','Lista_Distribuicao'])
df = pd.DataFrame()
Corp ['Num_CNPJ'] = Corp['Num_CNPJ'].astype(str)
Corp ['Num_CNPJ'] = Corp ['Num_CNPJ'].apply(lambda x: '{0:0>14}'.format(x))
Corp = df.insert(loc=0,column='Agencia_conta', value='--')
Corp = df.insert(loc=5,column='Email_cliente', value='--')
Corp = df.insert(loc=7,column='Telefone_gerente', value='--')
#config SCIB
Scib ['Num_CNPJ'] = Scib['CNPJ'].astype(str)
Scib ['Num_CNPJ'] = Scib['Num_CNPJ'].apply(lambda x: '{0:0>14}'.format(x))
Scib = df.insert(loc=0,column='Agencia_conta', value='--')
Scib = df.insert(loc=5,column='Email_cliente', value='--')
Scib = df.insert(loc=7,column='Telefone_gerente', value='--')
#config GI
Gi['Num_CNPJ'] = Gi ['Num_CNPJ'].astype(str)
Gi['Num_CNPJ'] = Gi ['Num_CNPJ'].apply(lambda x: '{0:0>14}'.format(x))
Gi = df.insert(loc=0,column='Agencia_conta', value='--')
Gi = df.insert(loc=5,column='Email_cliente', value='--')
Gi = df.insert(loc=7,column='Telefone_gerente', value='--')
#config UNIV
Univ ['Num_CNPJ'] = Univ ['Num_CNPJ'].astype(str)
Univ ['Num_CNPJ'] = Univ ['Num_CNPJ'].apply(lambda x: '{0:0>14}'.format(x))
Univ = df.insert(loc=0,column='Agencia_conta', value='--')
Univ = df.insert(loc=5,column='Email_cliente', value='--')
Univ = df.insert(loc=7,column='Telefone_gerente', value='--')
df = df.append (Corp)
df = df.append (Scib)
df = df.append (Gi)
df = df.append (Univ)
df = df.iloc [:,[0,3,4,5,6,12,13,9,14,23,2]]
df.to_excel ('C:/Users/t718787/Desktop/fotos/DBM_prt.xlsx', index = False)
print(df.count())
Juan, I did as I said, I created the spreadsheet and it worked, vlw on, thank you very much for your help!
– Indiano11
I’m glad this idea was able to help you!
– Juan Caio