0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

hstackやvstackでできないことをdstackで

Posted at
a = np.array(['1', '2'])
b = np.array(['a', 'b'])

aとbを合わせて次のようにしたい

array([['1', 'a'],
       ['2', 'b']])

hstackやvstackでできなかったので下記のようにやった。

>>>np.dstack((a, b))
array([[['1', 'a'],
        ['2', 'b']]])
>>>np.dstack((a, b)).shape
(1, 2, 2)
>>>c.reshape(c.shape[1], c.shape[2])
array([['1', 'a'],
       ['2', 'b']], dtype='<U1')
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?