Created
December 7, 2018 19:32
-
-
Save mGalarnyk/10d6648be653a7b6069928bed8121307 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
term = 60 | |
P = 34689.96 | |
def calc_interest(P,emi,interest_rate = 0.0702): | |
interest_paid = np.floor(((interest_rate/12)*P)*100)/100 | |
principal_paid = np.round(emi-interest_paid, 2) | |
new_balance = np.round(P - principal_paid,2) | |
return(emi, interest_paid, principal_paid, new_balance) | |
payment_list = [] | |
for n in range(1, term + 1): | |
emi,i_paid,p_paid,new_p = calc_interest(P, emi) | |
payment_list.append([n, P, emi, i_paid, p_paid, new_p]) | |
P = np.round(new_p,2) | |
c_names = ['Month','Starting Balance','Repayment','Interest Paid','Principal Paid','New Balance'] | |
payment_table = pd.DataFrame(payment_list, columns = c_names) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment