0

I got two arrays, the one is(array A[10][10000]):

 1:   [[   0    0    0 ...,  156  665  621]
 2:    [   0    0    0 ..., -187 -186 -186]
 3:    [   0    0    0 ...,   61  -22  -55]
       ..., 
 8:    [   0    0    0 ...,  540  402  496]
 9:    [   0    0    0 ...,   31   31   33]
10:    [   0    0    0 ..., -525 -504 -492]]

length is 10*10000,type is <type 'numpy.ndarray'> ,and dtype is int16

anothor one is(array B[10]) : b=numpy.arange(10)

[   0    1    2 ..., 7 8 9]

length is 10, type is <type 'numpy.ndarray'>, and dtype is int32

and I wish to convert this two different dimension arrays to one tuple like this(tuple C):

(array([[ 0,  0,  0, ...,  156,  665,  621],
        [ 0,  0,  0, ..., -187, -186,    0],
        [ 0,  0,  0, ...,   61,  -22,  -55],
        ..., 
        [ 0,  0,  0, ...,  540,  402,  496],
        [ 0,  0,  0, ...,   31,   31,   33],
        [ 0,  0,  0, ..., -525, -504, -492]], dtype=int16),
 array( [ 0,  1,  2, ...,    7,    8,    9], dtype=int32))

more information about tuple C:

print A[0].shape = (10, 10000)
print A[0].dtype.name = int16
print type(A[0]) = <type 'numpy.ndarray'>

print A[1].shape  = (10,)
print A[1].dtype.name = int32
print type(A[1]) = <type 'numpy.ndarray'>
2
  • You can just do C = (A, B) right? Commented Oct 9, 2013 at 11:43
  • That's amazing. I was trying to use tuple(map(tuple,A)), or np.vstack, np.append, np.concatenate. Thank you. :) Commented Oct 9, 2013 at 13:35

1 Answer 1

2

Unless I am missing something, you just want a tuple with the two arrays as elements:

C = (A, B)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.