i made a user defined function with 4 arguements. these 4 arguements are the 4 columns of the panda dataframe. how do i apply it? i wish to make a new column to store all the return values from the user defined function.
this is my user defined function:
i have a panda data frame which consist of 200 rows and 4 columns, the 4 columns store the values for the
fv, cp_rate, maturity_year and coupon_per_year.
how do i apply the user defined function and store the answers in a new column?
this is my user defined function:
cash_flow_list = []
def all_cash_flows (fv, cp_rate, maturity_year, coupon_per_year):
for i in range (1,maturity_year*coupon_per_year + 1):
if i == (maturity_year*coupon_per_year):
cash_flow_list.append((fv*cp_rate/coupon_per_year) + fv )
else:
cash_flow_list.append((fv*cp_rate/coupon_per_year))
return (cash_flow_list)(only 1 value will be returned. i need the values for my 200 rows of panda data frame)i have a panda data frame which consist of 200 rows and 4 columns, the 4 columns store the values for the
fv, cp_rate, maturity_year and coupon_per_year.
how do i apply the user defined function and store the answers in a new column?
