numpy_financial.nper#
- numpy_financial.nper(rate: float | Decimal | floating[Any] | integer[Any] | bool | object_, pmt: float | Decimal | floating[Any] | integer[Any] | bool | object_, pv: float | Decimal | floating[Any] | integer[Any] | bool | object_, fv: float | Decimal | floating[Any] | integer[Any] | bool | object_ = 0, when: str | int | NDArray[Any] | Iterable[str | int] = 'end') float#
- numpy_financial.nper(rate: _CanArrayAndLen[floating[Any] | integer[Any] | bool | object_] | _NestedSequence[float | Decimal | floating[Any] | integer[Any] | bool | object_], pmt: float | Decimal | _CanArray[floating[Any] | integer[Any] | bool | object_] | _NestedSequence[float | Decimal | floating[Any] | integer[Any] | bool | object_], pv: float | Decimal | _CanArray[floating[Any] | integer[Any] | bool | object_] | _NestedSequence[float | Decimal | floating[Any] | integer[Any] | bool | object_], fv: float | Decimal | _CanArray[floating[Any] | integer[Any] | bool | object_] | _NestedSequence[float | Decimal | floating[Any] | integer[Any] | bool | object_] = 0, when: str | int | NDArray[Any] | Iterable[str | int] = 'end') NDArray[float64]
- numpy_financial.nper(rate: ArrayLike | _NestedSequence[Decimal] | Decimal, pmt: ArrayLike | _NestedSequence[Decimal] | Decimal, pv: ArrayLike | _NestedSequence[Decimal] | Decimal, fv: ArrayLike | _NestedSequence[Decimal] | Decimal = 0, when: str | int | NDArray[Any] | Iterable[str | int] = 'end') Any
Compute the number of periodic payments.
decimal.Decimaltype is not supported.- Parameters:
- ratearray_like
Rate of interest (per period)
- pmtarray_like
Payment
- pvarray_like
Present value
- fvarray_like, optional
Future value
- when{{‘begin’, 1}, {‘end’, 0}}, {string, int}, optional
When payments are due (‘begin’ (1) or ‘end’ (0))
Notes
The number of periods
nperis computed by solving the equation:fv + pv*(1+rate)**nper + pmt*(1+rate*when)/rate*((1+rate)**nper-1) = 0
but if
rate = 0then:fv + pv + pmt*nper = 0
Examples
>>> import numpy as np >>> import numpy_financial as npf
If you only had $150/month to pay towards the loan, how long would it take to pay-off a loan of $8,000 at 7% annual interest?
>>> print(np.round(npf.nper(0.07/12, -150, 8000), 5)) 64.07335
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.
>>> rates = [0.05, 0.06, 0.07] >>> payments = [100, 200, 300] >>> amounts = [7_000, 8_000, 9_000] >>> npf.nper(rates, payments, amounts).round(3) array([[[-30.827, -32.987, -34.94 ], [-20.734, -22.517, -24.158], [-15.847, -17.366, -18.78 ]], [[-28.294, -30.168, -31.857], [-19.417, -21.002, -22.453], [-15.025, -16.398, -17.67 ]], [[-26.234, -27.891, -29.381], [-18.303, -19.731, -21.034], [-14.311, -15.566, -16.722]]])