Calculating multiple IRRs from a panda dataframe

242 Views Asked by At

I have a Panadas dataframe which encompasses 4 columns (company, price today, cash flow y1, cash flow y2, cash flow y3 (i.e. a terminal value)):

Code Price 0 1 2
GOOGL-US -2380 0 0 4074.94
AMZN-US -3265 0 0 5765.09
FB-US -327 0 0 513.819

etc for ~100 tickers

Is there a way to do a simple IRR calc using the data from the columns price, 0, 1, 2 as at annual periods (i.e. t0, t1, t2, t3)?

Thank you!

1

There are 1 best solutions below

1
On

I don't have concrete solution but could give you some hint and direction to look for. There had been a Numpy function Numpy.irr() supporting IRR calculation in Numpy / Pandas. However, it had been deprecated since Numpy version 1.18 and moved to separate module at NumPy Financial where you can still install it e.g. by:

pip install numpy-financial

Then use it as, e.g.

import numpy_financial as npf

npf.irr([-250000, 100000, 150000, 200000, 250000, 300000])
0.5672303344358536

You can refer to this article Calculating IRR in Python for some usage examples.