notebook.community
Edit and run
A função np.resize recebe um array a e retorna um array com o shape desejado. Caso o novo array seja maior que o array original o novo array é preenchido com cópias de a.
In [2]: import numpy as np a = np.array([[0,1],[2,3]]) print('a = \n', a) print() print('np.resize(a,(1,7)) = \n', np.resize(a,(1,7))) print() print() print('np.resize(a,(2,5)) = \n', np.resize(a,(2,5)))
import numpy as np a = np.array([[0,1],[2,3]]) print('a = \n', a) print() print('np.resize(a,(1,7)) = \n', np.resize(a,(1,7))) print() print() print('np.resize(a,(2,5)) = \n', np.resize(a,(2,5)))
a = [[0 1] [2 3]] np.resize(a,(1,7)) = [[0 1 2 3 0 1 2]] np.resize(a,(2,5)) = [[0 1 2 3 0] [1 2 3 0 1]]