AppDividend
Latest Code Tutorials

Numpy npv: How to Use np npv() Method in Python

Python numpy npv() is a financial function that is used to calculate the NPV ( Net Present Value) of the cash flow series. NPV is the present value (PV) of all cash flows (where inflows are positive cash flows, and outflows are negative), which means the NPV can be called a revenue formula minus costs. 

The NPV is solved using the following equation.

Python numpy npv()

NumPy npv()

Python numpy.npv(rate, value) is an inbuilt NumPy financial function that helps the user to calculate an NPV(Net Present Value) of the cash flow series. NumPy npv() is an inbuilt statistic function that can decide if an investment opportunity is a smart financial choice, or not.

Syntax

numpy.npv(rate, values)

The numpy npv() function can take up to two parameters:

  1. rate: This indicates the rate of the discount.
  2. values: The values of the time series of cash flows. The (fixed) period between cash flow “events” must be the same as that for which rate is given (i.e., if the rate is per year, then precisely one year for each cash flow event is understood to elapse). By definition, investments or “deposits” are negative, income or “withdrawals” are positive; values must start with the initial investment, so usually negative values[0] are.

Return Value

The npv() function returns NPV values as per the given value.

Programming to show the working of npv()

#Program to show working of NPV
import numpy as np

#declaring values
values = [45, 50, 40, -100]
rate1 = 0.50
rate2 = 0.30
rate3 = 1
#Printing NPV Values
print("NPV value with rate ", rate1, " is: ", np.npv(rate1, values))
print("NPV value with rate ", rate2, " is: ", np.npv(rate2, values))
print("NPV value with rate ", rate3, " is: ", np.npv(rate3, values))

Output

NPV value with rate  0.5  is:  66.48148148148148
NPV value with rate  0.3  is:  61.61356395084205
NPV value with rate  1  is:  67.5

Explanation

In this example, we have first declared an array named ‘values’ in which we have stored all the values then we have assigned 3 ‘rate’ values. Then we have called npv() with three different rates and then printed them. NPV is calculated using the above equation. 

Conclusion

If you want to find the NPV (Net Present Value) of a cash flow series in Python, then use the numpy npv() function.

See also

NumPy reshape()

NumPy place()

NumPy identity()

NumPy roll()

NumPy eye()

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.