How to Calculate the IRR using numpy_financial

To calculate the IRR using numpy_financial:

import numpy_financial as npf

irr = npf.irr([initial investment in negative terms, cash flows each year separated by commas])

print(irr)

Steps to calculate the IRR using numpy_financial

Step 1: Install the numpy_financial package

If you haven’t already done so, install the numpy_financial package using:

pip install numpy_financial

Step 2: Calculate the IRR using numpy_financial

Imagine that you have the following information about a project:

  • The initial investment is $1700
  • The project is expected to generate:
    • $500 in year-1
    • $750 in year-2
    • $800 in year-3

What is the IRR?

To calculate the IRR, you’ll need to apply this code in Python:

import numpy_financial as npf

irr = npf.irr([-1700, 500, 750, 800])

print(irr)

And if you run this code, you’ll get the IRR of 0.09236 (or 9.236%).