Below is a code snippet from the “Python, Numpy, Vectorization optional lab”:
a = np.arange(6).reshape(-1, 2) #reshape is a convenient way to create matrices
With this code, are we reshaping the array [1,2,3,4,5,6] into a matrix with -1 rows and 2 columns? What does “-1” mean in this case and how do the parameters -1 and 2 lead to the array being reshaped into a matrix with 3 rows and 2 columns?
Thank you!