Creating a Loan Calculator Dashboard with Python and Streamlit
Have you ever wondered how your loan payments break down over time? How much of your monthly payment goes towards interest and how much towards paying off the principal? With the loan calculator dashboard I’ve created using the Python library Streamlit, you can easily find out!
You can find it running on the following link: https://krinya-loan-calculation-loan-dashboard-ox0kk4.streamlit.app/
The dashboard allows users to input the principal amount, interest rate, and term of the loan (in months) and then calculate the monthly breakdown of the loan payments. The results are displayed in a table that shows the month, monthly payment, interest amount, remaining principal, and total amount paid for each month of the loan.
In addition to the monthly breakdown, the dashboard also includes plots that show the remaining principal over time, the interest paid over time, and the ratio of interest paid to monthly installment over time. This allows users to easily visualize how the loan payments are being applied over the term of the loan.
Furthermore, I included a feature that allows users to download the monthly breakdown data as a CSV file, so they can analyze the data or use it in other projects.
Get Kristóf Menyhért’s stories in your inbox
Join Medium for free to get updates from this writer.
If you’re interested in running the dashboard yourself, the code is available on my GitHub at the following link: https://github.com/krinya/loan_calculation.
Here is a summary of what I have done in the code:
First, we will start by importing the necessary libraries, including Streamlit, Pandas, and Plotly. We then define a function to calculate loan data based on the input values of principal, rate, and term. This function calculates the monthly interest rate, monthly payment, and remaining principal, as well as the total amount paid over the loan term. Additionally, we create a dataframe to store the results of each iteration and create a new column ‘interest_monthly_ratio’
Next, we create the user interface of the dashboard using Streamlit. We use the st.columns() function to divide the dashboard into three columns, where the user can input the principal amount, interest rate, and loan term. We then call the loan_amount function and pass in the user input values as arguments.
After that, we create three line graphs using Plotly, one for the remaining principal over time, one for the interest paid over time, and one for the interest payment / monthly installment ratio over time. We then display the monthly installment and total amount paid at the end of the loan period. And we create a checkbox that allows users to show the loan breakdown per month and download the data as a CSV file.
Give it a try and see how your loan payments break down!
And I would really appreciate it if you could subscribe to me. I still do not have 100 Medium subscribers, so by subscribing, you would be supporting me and helping me to continue to create valuable content for you.









