NumPy Financial functions: nper() function
numpy.nper() function
The nper() function is used to compute the number of periodic payments.
decimal.Decimal type is not supported.
Syntax:
numpy.nper(rate, pmt, pv, fv=0, when='end')
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
rate | Rate of interest (per period) array_like |
Required |
pmt | Payment array_like |
Required |
pv | Present value array_like |
Required |
fv | Future value array_like |
Optional |
when | When payments are due ('begin' (1) or 'end' (0)) {{'begin', 1}, {'end', 0}}, {string, int} |
Optional |
Notes:
The number of periods nper is computed by solving the equation:
fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate*((1+rate)**nper-1) = 0
but if rate = 0 then:
fv + pv + pmt*nper = 0
NumPy.nper() method Example-1:
If you only had $200/month to pay towards the loan, how long would it take to pay-off a loan of $10,000 at 8% annual interest?
>>> import numpy as np
>>> print(np.round(np.nper(0.08/12, -200, 10000), 2))
Output:
61.02
NumPy.nper() method Example-2:
So, over 64 months would be required to pay off the loan.
The same analysis could be done with several different interest rates and/or payments and/or total amounts to produce an entire table.
>>> import numpy as np
>>> np.nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
... -150 : -99 : 50 ,
... 8000 : 9001 : 1000]))
Output:
array([[[ 64.07334877, 74.06368256], [108.07548412, 127.99022654]], [[ 66.12443902, 76.87897353], [114.70165583, 137.90124779]]])
Python - NumPy Code Editor:
Previous: mirr() function
Next: rate() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/numpy/financial-functions/nper.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics