this question has answer here:
i have name list, , want construct new list of same type of data inside list. how can it? if numpy array?
x=[1,2,3,4] newx=[x,5,6] [[1, 2, 3, 4], 5, 6] #numpy y=np.array([0,1,2,3,4]) newy=[y,5,6] [array([0, 1, 2, 3, 4]), 5, 6]
desired output
[1, 2, 3, 4, 5, 6]
for mere python lists do:
x = [1, 2, 3, 4] x += [5, 6] >>> [1, 2, 3, 4, 5, 6]
and numpy-arrays:
x = np.array([1, 2, 3, 4]) x = np.concatenate((x, np.array([5, 6]))) >>> np.array([1, 2, 3, 4, 5, 6])
mind double parentheses in np.concatenate, since arguments must passed tuple.
Comments
Post a Comment