I'm creating an amortization table and have 30 periods, index is 1-30. Problem is particular loans haven't come to the end of the 30 periods yet so I have a variable that can change each period. I have a value for 17 rows, then nothing. How do I get my variable to fill down to the 30th row with the 17th (last) value in the for loop?
beginning_bal = loan_amt principal = round(nf.ppmt(pv=loan_amt, rate=adj_interest_rate, nper=num_periods, per=num_periods, fv=0), 2) interest = nf.ipmt(pv=loan_amt, rate=adj_interest_rate, nper=num_periods, per=num_periods, fv=0) ending_bal = nf.pv(fv=0, pmt=pmt, rate=adj_interest_rate, nper=0) records=[] end_bal = loan_amt cum_int = 0.0 cof = 0.0 rt_npv = 0 for i in range(1, len(rng)+1): bgn_bal = end_bal principal = nf.ppmt(pv=loan_amt, rate=adj_interest_rate, nper=num_periods, per=i, fv=0) interest = float(nf.ipmt(pv=loan_amt, rate=adj_interest_rate, nper=num_periods, per=i, fv=0)) end_bal = nf.pv(fv=0, pmt=pmt, rate=adj_interest_rate, nper=len(rng)-i) monthly_co = loan_amt*co_rate npv_rate = 1.2**(i / num_payments_per_yr) npvper = -pmt / (npv_rate + co_rate + (.014*(12/num_payments_per_yr))) #20% discount, charge off rate, early payoff rate rt_npv += npvper cof += bgn_bal * .0083 #COF basis llr_rate.replace({'llr_rate': {0: np.nan}}).ffill() prin_llr = bgn_bal * llr_rate int_llr = -interest * llr_rate cum_int += interest net_revenue = (-cum_int - cof - monthly_co - prin_llr - int_llr) records.append((bgn_bal, -pmt, -principal, -interest, -cum_int, end_bal, monthly_co, npvper, rt_npv, npv_rate, cof, prin_llr, int_llr, net_revenue))
fillna()withmethod='ffill'.