Skip to content

Instantly share code, notes, and snippets.

@mGalarnyk
Created December 7, 2018 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mGalarnyk/10d6648be653a7b6069928bed8121307 to your computer and use it in GitHub Desktop.
Save mGalarnyk/10d6648be653a7b6069928bed8121307 to your computer and use it in GitHub Desktop.
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