import numpy as np
A = np.array([1,1,1])
B = np.array([2,2,2])
C = np.vstack((A,B))
print C
[[1 1 1]
[2 2 2]]
D = np.hstack((A,B))
print D
[1 1 1 2 2 2]
AA = A[:,np.newaxis]
print AA
[[1]
[1]
[1]]
BB = B[:,np.newaxis]
DD = np.hstack((AA,BB))
print DD
[[1 2]
[1 2]
[1 2]]
CC = np.concatenate((AA,BB),axis=1)
print CC
[[1 2]
[1 2]
[1 2]]
import numpy as np
A = np.arange(12).reshape((3,4))
print A
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
print np.split(A,2,axis=1)
[array([[0, 1],
[4, 5],
[8, 9]]), array([[ 2, 3],
[ 6, 7],
[10, 11]])]
print np.array_split(A,3,axis=1)
[array([[0, 1],
[4, 5],
[8, 9]]), array([[ 2],
[ 6],
[10]]), array([[ 3],
[ 7],
[11]])]
print np.vsplit(A,3)
print np.hsplit(A,2)
[array([[0, 1, 2, 3]]), array([[4, 5, 6, 7]]), array([[ 8, 9, 10, 11]])]
[array([[0, 1],
[4, 5],
[8, 9]]), array([[ 2, 3],
[ 6, 7],
[10, 11]])]
a = np.arange(4)
print a
[0 1 2 3]
b = a
c = a
d = b
a[0] = 10
print b is a
print c is a
print d is a
True
True
True
d[1:3] = [22,11]
print a
[10 22 11 3]
e = a.copy()
print e
a[1] = 100
print e is a
[ 10 100 11 3]
False