0

I am trying to get XIRR for each customer with multiple entries with dates and payments in float. I want to find XIRR for each customer by grouping them with Unique ID

Code I am trying

import pandas as pd

from pyxirr import xirr

result = df.groupby("ID")[["date","payment"]].apply(xirr)`

where df id my dataframe and ID, date and payment are my columns

I am getting error as InvalidPaymentsError: negative and positive payments are required

Ajit
  • 39
  • 6

1 Answers1

0

In order to calculate XIRR, you need both positive and negative payments. This error means that some of the groups have only negative or only positive payments. You can suppress this exception by using silent=True parameter (link).

df.groupby("ID")[["date","payment"]].apply(xirr, silent=True)
Alexander Volkovsky
  • 2,588
  • 7
  • 13