The numpy-financial Python package is a collection of elementary financial functions. These functions were copied to this package from version 1.17 of NumPy.
The financial functions in NumPy are deprecated and eventually will be removed from NumPy; see NEP-32 for more information. This package is the replacement for the deprecated NumPy financial functions.
The package is available on PyPI, and may be installed
with pip
:
$ pip install numpy-financialThe package requires NumPy version 1.15 or later.
numpy_financial
The importable name of the package is numpy_financial
.
The recommended alias is npf
. For example,
>>> import numpy_financial as npf >>> npf.irr([-250000, 100000, 150000, 200000, 250000, 300000]) 0.5672303344358536
numpy
to numpy_financial
Code that imports the function names like this
from numpy import npv, irrrequires only that the import be changed to
from numpy_financial import npv, irr
For code that uses the numpy
namespace like this
import numpy as np x = np.array([-250000, 100000, 150000, 200000, 250000, 300000]) r = np.irr(x)the import statement for the numpy-financial package must be added, and the calls of the financial functions must be changed to use the
npf
namespace:
import numpy as np import numpy_financial as npf x = np.array([-250000, 100000, 150000, 200000, 250000, 300000]) r = npf.irr(x)