10 Array variable dimension of Python Numpy library

10 Make changes to array dimensions

a = np.random.randint(1,26, size = 28)
print(a)
b = a.reshape(2,2,7)
print(b)

vv = np.reshape(a,(2,2,7))
print(vv)
cc = vv.reshape(28)
cc = vv.reshape(-1)
print(cc)

Convert multi-dimensional array into a group of arrays through ravel and flatten functions

a = b.ravel()
dd = b.flatten()
print(a)
print(dd)
Published 36 original articles · praised 0 · visits 637

Guess you like

Origin blog.csdn.net/Corollary/article/details/105377749