The . . . . . . . . function returns its argument with a modified shape, whereas the . . . . . . . . method modifies the array itself.

reshape, resize
resize, reshape
reshape2, resize
all of the mentioned

The correct answer is: A. reshape, resize

The reshape function returns a new array with the specified shape, while the resize method modifies the shape of the existing array.

For example, the following code reshapes the array a to have a shape of (2, 3):

“`

a = np.array([[1, 2, 3], [4, 5, 6]])
a.reshape(2, 3)
array([[1, 2, 3],
[4, 5, 6]])
“`

The following code resizes the array a to have a shape of (6):

“`

a.resize(6)
array([1, 2, 3, 4, 5, 6])
“`

Note that the reshape function can only change the shape of an array, while the resize method can also change the size of an array.

Exit mobile version