I have this problem in Python and I cannot figure out how I can do this. I have three arrays:
Two of the form:
array1 ([ 1, 2, 3])
array2 ([ 4, 5, 6])
and one of the form:
array3 ([ [1, 2, 3], [2, 3, 4], [3, 4, 5]])
What I want is an array from these two arrays which has three columns, in such a way, that the 2D array is in the center:
array ([1, [1, 2, 3], 4],
[2, [2, 3, 4], 5],
[3, [3, 4, 5], 6])
I am able to join the first two arrays by using e.g. np.c_[array1, array2].
I can do np.c_[array1, array3, array2] as well, but then I get
array ([1, 1, 2, 3, 4],
[2, 2, 3, 4, 5],
[3, 3, 4, 5, 6])
Any help is appreciated. Thanks.
numpyarrays. Jagged arrays are a bad idea.[list(el) for el in zip(array1, array3, array2)]arrayword is just tacked on. It's not a valid array constructor or display, not even forobjectdtype.