I am very new to Python (previous Matlab user).
I have the array
y_pred = [None] * 128
test_idx is an array of indeces
array([ 3, 4, 5, 19, 28, 30, 38, 39, 47, 49, 50, 51, 54,
64, 74, 81, 84, 85, 90, 91, 93, 97, 102, 103, 106, 107,
109, 111, 115, 121], dtype=int64)
I would like to replace the values of y_pred corresponding to the test_idx with the array results
array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0])
if I try
y_pred[test_idx] = results
I get the error: TypeError: only integer arrays with one element can be converted to an index
y_predis not an array, but alist, which can't be indexed like that. Perhaps use an array instead?numpytag is you are going to ask a question aboutnumpyarrays.y_pred`` to be a list ofNone`s? Not array of zeros? What's the Matlab equivalent?