a = np.arange(12)
b = a
print (b is a)
b.shape = 3,4
print (a.shape)
print (id(a))
print (id(b))

>>>
True
(3, 4)
2052537612608
2052537612608

c = a.view()#潜复制
print (c is a)
c.shape = 2,6
print (a.shape)
c[0,4] = 1234
print (a)
print (id(a))
print (id(c))

>>>
False
(3, 4)
[[   0    1    2    3]
 [1234    5    6    7]
 [   8    9   10   11]]
1974659569504
1974659621312


d = a.copy() #深复制
print(d is a)
d[0,0] = 9999
print (d) 
print (a)
>>>
False
[[9999    1    2    3]
 [   4    5    6    7]
 [   8    9   10   11]]
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]
复制
a = np.array([[4, 3, 5], [1, 2, 1]])
print (a)
print ('--------')
b = np.sort(a, axis=1)#从小到大排序方法一
print (b)
a.sort(axis=1)#从小到大排序方法二
print ('--------')
print (a)

>>>
[[4 3 5]
 [1 2 1]]
--------
[[3 4 5]
 [1 1 2]]
--------
[[3 4 5]
 [1 1 2]]
a = np.array([4, 3, 1, 2])
j = np.argsort(a)
print ('--------')
print (j)
print ('--------')
print (a[j])

>>>
--------
[2 3 1 0]
--------
[1 2 3 4]