Help us understand the problem. What is going on with this article?

Numpyで行列の連結

More than 1 year has passed since last update.

【追記】 学生のときに血迷ってこのようなメモを書きましたが、冷静にnp.concatenateを使って下さい: https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html


どっちがどっちかよく忘れるのでメモ.

>>> import numpy as np
>>> a = np.array([[1,2,3], [4,5,6]])
>>> b = np.array([[7, 8, 9], [10, 11, 12]])
>>> c = np.array((1, 2, 3))
>>> d = np.array((4, 5, 6))

>>> a
array([[1, 2, 3],
       [4, 5, 6]])

>>> b
array([[ 7,  8,  9],
       [10, 11, 12]])

>>> c
array([1, 2, 3])

>>> d
array([4, 5, 6])

>>> np.r_[a, b]
array([[ 1,  2,  3],
       [ 4,  5,  6],
       [ 7,  8,  9],
       [10, 11, 12]])

>>> np.c_[a, b]
array([[ 1,  2,  3,  7,  8,  9],
       [ 4,  5,  6, 10, 11, 12]])

>>> np.r_[c, d]
array([1, 2, 3, 4, 5, 6])

>>> np.c_[c, d]
array([[1, 4],
       [2, 5],
       [3, 6]])

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away