Open

0

# Differences in python array reshape scenarios

What is the difference between the following: import numpy as np x = np.array([[1, 2], [3, 4], [5, 6]]) z = x.reshape(6) print(z) As opposed to: import numpy as np x = np.array([[1, 2], [3, 4], [5, 6]]) z = x.reshape(1,6) print(z) You get slightly different outputs. What exactly is the difference?

2 Answers

+ 2

Reshape means you are shaping element in number of rows and column
in, x.reshape(6)
Will give you a Single Dimension Array
[ 1 2 3 4 5 6 ]
But x.reshape(1,6)
Will give a double dimension array of 6 column and 1 row.
[[1 2 3 4 5 6]]

0

Thanks for the response. How is the second case considered a 2d dimension?