I am inserting data from a dataframe df with 55 rows into a numpy array matrix_of_coupons_and_facevalues with a shape of (55,60). I am doing this using the code below. However, I get the error IndexError: index 55 is out of bounds for axis 0 with size 55. months_to_maturity contains the numbers [6:6:330].
for (i,row) in df.iterrows():
matrix_of_coupons_and_facevalues[i,0:(row.months_to_maturity/ 6)-1] = 1/2
matrix_of_coupons_and_facevalues[i,(row.months_to_maturity/6)-1] = 3/2
Thank You
dfdoes indeed have 55 rows? From the looks of the code, it seems likeiis getting a value of 55, which could only occur ifdfhad more than 55 rows. Perhaps you could try something likeprint(len(list(df.iterrows())))to see if it is indeed 55.print(len(list(df.iterrows())))results in 55.