Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
numpy_financial.pmt() in Python
Next article icon

numpy_financial.pmt() in Python

Last Updated : 19 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

numpy_financial.pmt() function in Python is part of the numpy-financial library and is used for calculating the payment amount required for a loan or an investment, assuming that payments are constant and the interest rate remains unchanged throughout the term. This function is particularly useful for financial calculations involving loans, mortgages, or other types of payments spread over a series of periods.

To use the numpy_financial.pmt() function in Python, you need to install the numpy-financial library, which is an extension of NumPy for financial calculations. You can install the numpy-financial library using pip (Python's package manager):

pip install numpy-financial

Example:

Let’s calculate the monthly payment required for a $10,000 loan over 5 years with an annual interest rate of 6%.

Python
import numpy_financial as npf  # Given values rate = 0.06 / 12   nper = 12 * 5      pv = 10000           # Calculate monthly payment payment = npf.pmt(rate, nper, pv)  print(f"Monthly payment: {payment:.2f}") 

Output

Monthly payment: -193.33

Explanation:

  • rate = 0.06 / 12: Converts the annual interest rate (6%) to a monthly interest rate.
  • nper = 12 * 5: Calculates the total number of periods (12 months per year for 5 years).
  • pv = 10000: The loan amount is 10,000.

Understanding the Formula

The numpy_financial.pmt() function solves the following equation for the payment (pmt):

f v + p v \times (1 + rate)^{nper} + pmt \times \frac{(1 + rate \times when)}{rate} \times \left( (1 + rate)^{nper} - 1 \right) = 0

Syntax

numpy_financial.pmt(rate, nper, pv, fv=0, when='end')

Parameters

  • rate: The interest rate for each period.
  • nper: The total number of periods (e.g., months or years).
  • pv: The present value (the loan amount or investment).
  • fv: The future value, or the desired loan balance after the last payment (default is 0).
  • when : Specifies whether the payment is made at the 'end' (default) or 'begin' of each period.

Return Value

The function returns the payment amount for each period.

Example of numpy_financial.pmt()

1. Investment Payment Calculation

Suppose we want to make monthly payments into an account with a future value of $50,000 after 10 years, assuming an annual interest rate of 4%.

Python
import numpy_financial as npf  # Parameters rate = 0.04 / 12   nper = 10 * 12   fv = 50000    # Calculate the monthly payment payment = npf.pmt(rate, nper, 0, fv)  print(f"Monthly Payment: ${payment:.2f}") 

Output

Monthly Payment: $330.09

Explanation:

  • The interest rate is converted to a monthly rate by dividing the annual rate (4%) by 12.
  • The number of payments is calculated by multiplying 10 years by 12 months.
  • The npf.pmt() function calculates the amount you need to pay monthly to achieve a future value of $50,000.

2. Mortgage Payment Calculation

In this example, we'll calculate the monthly mortgage payment for a house loan. You borrow $250,000 for 30 years at an annual interest rate of 3.5%. We will calculate the monthly payment using numpy_financial.pmt().

Java
import numpy_financial as npf  # Parameters rate = 0.035 / 12  # Monthly interest rate (annual rate divided by 12) nper = 30 * 12  # Total number of payments (30 years with monthly payments) pv = 250000  # Present value (loan amount)  # Calculate the monthly mortgage payment payment = npf.pmt(rate, nper, pv)  print(f"Monthly Mortgage Payment: ${payment:.2f}") 

Output

Monthly Mortgage Payment: $1122.61

Explanation:

  • The rate is calculated by dividing the annual interest rate 3.5% by 12 to get the monthly interest rate.
  • The nper is calculated by multiplying 30 years by 12 months.
  • The npf.pmt() function is used to calculate the monthly payment for the mortgage loan.

When to Use numpy_financial.pmt()

  • Loan Payments: When you need to calculate the monthly payment for a loan or mortgage with a fixed interest rate and a fixed term.
  • Investment Withdrawals: When calculating how much you can withdraw from an investment at regular intervals (like monthly) to deplete the entire amount by the end of a fixed term.
  • Annuities: Useful for calculating annuity payments when the principal amount is withdrawn periodically over a set term.

Next Article
numpy_financial.pmt() in Python

M

mohit gupta_omg :)
Improve
Article Tags :
  • Python
  • Python-numpy
  • Python numpy-Financial Functions
Practice Tags :
  • python

Similar Reads

    numpy.pmt() in Python
    numpy.pmt(rate, nper, pv, fv, when = ‘end’): This financial function helps user to compute payment value as per the principal and interest. Parameters : rate : [scalar or (M, )array] Rate of interest as decimal (not per cent) per period nper : [scalar or (M, )array] total compounding periods fv : [s
    1 min read
    numpy.ppmt() in Python
    numpy.ppmt(rate, nper, pv, fv, when = ‘end’) : This financial function helps user to compute payment value as per the principal value only. Parameters : rate : [scalar or (M, )array] Rate of interest as decimal (not per cent) per period nper : [scalar or (M, )array] total compounding periods fv : [s
    2 min read
    numpy.pv() in Python
    numpy.fv(rate, nper, pmt, fv, when = 'end') : This financial function helps user to compute future values. Parameters : rate : [array_like] Rate of interest as decimal (not per cent) per period nper : [array_like] total compounding periods pmt : [array_like] fixed payment fv : [array_like, optional]
    1 min read
    numpy.fv() in Python
    numpy.fv(rate, nper, pmt, pv, when = 'end') : This financial function helps user to compute future values. Parameters : rate : [scalar or (M, )array] Rate of interest as decimal (not per cent) per period nper : [scalar or (M, )array] total compounding periods pmt : [scalar or (M, )array] fixed payme
    1 min read
    numpy.irr() in Python
    numpy.irr(values) : This financial function helps user to compute IRR Value i.e. Internal Rate of Return ie. “average” periodically compounded rate of return.    Parameters : values : [array-like] Input cash flows per time period. net “deposits” are negative and net “withdrawals” are positiveReturn
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences