def npv(rate, flow, time_index, offset=1):
    """"Returns the Net Present Value (NPV) of a cash flow with equally spaced periods. The flow parameter must contain a series of periodic payments (negative values) and inflows (positive values), indexed by time_index.
        The optional offset parameter especifies the offset of the first value relative to the current time period. By default, offset is set to 1, indicating that the first value is discounted as if it is one step in the future
    """
    _number_of_periods = time_index.pos + offset
    _present_values = flow / (1 + rate) ** _number_of_periods
    _npv = _present_values.sum(axis=time_index)
    return _npv
