Best Answer · By JanBask Python Expert
Answered on Mar 2, 2021
The problem you have is that when you are attempting to build your h_matrix array, it finds that its columns don't all have a similar length. The h_column1_formula array contains 10 as length, the others are length 9.
So rather than building an array with a numeric data type, it utilizes dtype=object, since that underpins discretionary substance (counting arrays of various sizes). The matrix augmentation whines about this, as it doesn't uphold object arrays, just numeric ones.
To fix this, you most likely need to change a portion of the code you're utilizing to build the matrix. Either you need to run, bring on top of it or the np. rehash calls should be changed so the numbers line up appropriately.
I'd suggest either:
h_column1_formula = np.repeat(1, 9) # create an array with 9 values
OR
for maturity in range(1,11): # loop 10 times, 1-10
Improve your knowledge in data science from scratch using Data science online