import numpy as np
data = np.sin(np.arange(20)).reshape(5,4)
print (data)
print(10*"*")
ind = data.argmax(axis=0)
print (ind)
print(10*"*")
print(range(0,4))
print(10*"*")
data_max = data[ind, range(data.shape[1])]
print (data_max)
print(10*"*")
all(data_max == data.max(axis=0))
[[ 0. 0.84147098 0.90929743 0.14112001]
[-0.7568025 -0.95892427 -0.2794155 0.6569866 ]
[ 0.98935825 0.41211849 -0.54402111 -0.99999021]
[-0.53657292 0.42016704 0.99060736 0.65028784]
[-0.28790332 -0.96139749 -0.75098725 0.14987721]]
**********
[2 0 3 1]
**********
range(0, 4)
**********
[0.98935825 0.84147098 0.99060736 0.6569866 ]
**********
True
a = np.arange(0, 40, 10)
b = np.tile(a, (3, 5))
print (b)
[[ 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30]
[ 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30]
[ 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30 0 10 20 30]]
a = np.arange(0, 40, 10)
print a
print ‘—’
b = np.tile(a, (1, 4))
print b
#print a
#print b
a = np.array([[4, 3, 5], [1, 2, 1]])
print( a)
print(10*"*")
print(np.sort(a, axis=1))
print(10*"*")
print(np.sort(a,axis=0))
print(10*"*")
a = np.array([4, 3, 1, 2])
print (np.argsort(a))
print(10*"*")
print (a[j])
print(10*"*")
[[4 3 5]
[1 2 1]]
**********
[[3 4 5]
[1 1 2]]
**********
[[1 2 1]
[4 3 5]]
**********
[2 3 1 0]
**********
[1 2 3 4]
**********