0

I have a data set in Python Pandas that is similar to the table below in structure.

I am trying to add a new column that calculates the total NPV for each loan (adding up "NPV of loan payment calculated at the time of loan Issue date" per loan). I am expecting results to look like this:

I have tried writing for loops but I keep getting errors. Could anyone please help me with this?

  • Does this answers your question: https://stackoverflow.com/questions/30244952/how-do-i-create-a-new-column-from-the-output-of-pandas-groupby-sum? – Rustam A. Aug 25 '21 at 21:38

1 Answers1

0
df.groupby("LoanID",as_index=False)["NPV of loan payment calculated at the time of loan Issue date"].sum()