Suppose I have an array of arrays.
import numpy as np x = np.array([ [1, 2], [3, 4], [5, 6]])
I want to add 10 as the first element of each of those arrays without running for loop. Result should look like
array([[10, 1, 2], [10, 3, 4], [10, 5, 6]])
Plain append does not work.
np.append(10, x) array([10, 1, 2, 3, 4, 5, 6])
My original problem has 100K arrays. So I need to find an efficient way to do this.
https://stackoverflow.com/questions/67014535/append-an-element-to-array-of-arrays April 09, 2021 at 11:06AM
没有评论:
发表评论