1
Hello,
I am writing a code in python, using the citizen calculator library, to readjust the items of an LPU to register 12 months, the LPU will be inserted by an excel, the base date of the reajsute also and the result should also be written in excel. I can already do the readjustment but I’m having difficulty writing the loop for the calculation every 12 months.
#Reajuste de uma LPU utilizando um indice, via calculadora do cidadão
#bibliotecas
from datetime import date, datetime, timedelta
from decimal import Decimal
from calculadora_do_cidadao import Ipca, Igpm, Inpc
import pandas as pd
# indice de reajuste
ipca = Ipca()
igpm = Igpm()
inpc = Inpc()
#carregar da LPU em formato xls
lpu = pd.read_excel('C:/Users/Bruno/Downloads/teste_LPU_Greenwich.xlsx')
#carregar data de assinatura do cotrato
data_lpu= lpu.loc[14,'Greenwich']
print(data_lpu)
#carregar da de hoje
data_hj= (date.today()-timedelta(days=30))
print(data_hj)
#nova coluna
lpu['valor_reajustado',data_hj.year]='-'
#valor reajustado
for i in range(2,12):
valor_reajuste= ipca.adjust(data_lpu, int(lpu.loc[i,'Greenwich']),data_hj)
lpu.loc[i,('valor_reajustado',data_hj.year)] = round(valor_reajuste,3)
print(lpu)
#data_lpu_formatada= date.time(int(data_lpu[6:9]),int(data_lpu[4:5]),int(data_lpu[0:1])
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativations worth reading What is the Stack Overflow and then the Stack Overflow Survival Guide (summarized) in Portuguese.
– Bacco