import numpy as np
a=np.array([1, 3, 3], dtype='int8')
print(a)
[1 3 3]
b=np.array([[1, 3, 5], [2, 3, 5]])
print(b)
[[1 3 5] [2 3 5]]
b.shape=(1,6)
print(b)
[[1 3 5 2 3 5]]
b.shape=(3, 2)
print(b)
[[1 3] [5 2] [3 5]]
print(a.dtype)
int8
print(a.size*a.itemsize,
a.nbytes)
3 3
b[2, :]
array([3, 5])
b=np.array([[1, 2, 3]])
c=np.repeat(b, 3, axis=1)
print(c[0, ::2])
[1 1 2 3 3]
b[:, ::1]=[[1, 4, 5]]
d=np.random.rand(4,2)
print(d)
[[0.42195762 0.86498204] [0.91341263 0.33204442] [0.75985235 0.28298197] [0.69252822 0.57118244]]
c.shape=(3, 3)
x=np.full(c[1, ], 4)
print(c, " and ",x)
[[1 1 1] [2 2 2] [3 3 3]] and [[[4 4] [4 4]] [[4 4] [4 4]]]