Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Last active June 8, 2021 13:10
Show Gist options
  • Save ilonacodes/188483d747848d3c8d199da2e96ecfa0 to your computer and use it in GitHub Desktop.
Save ilonacodes/188483d747848d3c8d199da2e96ecfa0 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
r = 0.03
cash_flow = pd.DataFrame({'Year': [1, 2, 3, 4, 5, 6],
'Cash': [200, 200, 200, 200, 200, 200]})
# PV (Present Value) = Cash (at period 1) / (1 + r)^n
cash_flow['PV'] = cash_flow['Cash'] / (1.0 + r) ** cash_flow['Year']
npv = cash_flow['PV'].sum()
print(round(cash_flow))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment