LoginSignup
2
0

More than 5 years have passed since last update.

python: 配列の結合

Posted at

pythonで配列を結合する方法

以下のように,ndarrayの場合はnp.r_[配列A, 配列B]で結合可能.
listの場合は + を用いることで結合可能.

In [1]: import numpy as np

In [2]: a = np.array([1,2,3])

In [3]: b = np.array([4,5,6])

In [4]: np.r_[a, b]
Out[4]: array([1, 2, 3, 4, 5, 6])

In [5]: a = [1,2,3]

In [6]: b = [4,5,6]

In [7]: a + b
Out[7]: [1, 2, 3, 4, 5, 6]

2
0
0

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
2
0