About 50 results
Open links in new tab
  1. What does -1 mean in numpy reshape? - Stack Overflow

    Sep 9, 2013 · b = numpy.reshape(a, -1) you are only saying for the numpy.reshape to automatically calculate the size of the vector (rows x columns) and relocate it into a 1-D vector with that dimension.

  2. python - Reshape an array in NumPy - Stack Overflow

    Jan 23, 2013 · the "-1" is a wild card that will let the numpy algorithm decide on the number to input when the second dimension is 3 so yes.. this would also work: a = a.reshape(3,-1)

  3. python - How does numpy reshape works? - Stack Overflow

    Apr 2, 2015 · How does numpy reshape works? Ask Question Asked 11 years ago Modified 3 years, 5 months ago

  4. NumPy using the reshape function to reshape an array

    Mar 30, 2020 · 2 This question already has an answer here: how to reshape an N length vector to a 3x (N/3) matrix in numpy using reshape (1 answer)

  5. Understanding the performance behavior of numpy.reshape

    Aug 29, 2023 · analysis reshape/ravel has to take the reordered version, and traverse the values in the order specified by the strides, iterating with the smallest first. Someone else with a better sense of …

  6. python - Arrays of size 0 in NumPy - Stack Overflow

    Feb 25, 2025 · arr.reshape((-1,0)) # ValueError: cannot reshape array of size 0 into shape (0) I always thought that -1 for a reshape operation means the product of all the remaining dimensions, i.e., 1 in …

  7. python - numpy reshape implementation - Stack Overflow

    Dec 31, 2023 · ndarray.reshape(shape, order='C') why this method on ndarray allows the elements of the shape parameter to be passed in as separate arguments? That is, why does this implementation …

  8. Convert a 1D array to a 2D array in numpy - Stack Overflow

    Sep 25, 2012 · I want to convert a 1-dimensional array into a 2-dimensional array by specifying the number of columns in the 2D array. Something that would work like this: > import numpy as np > A = …

  9. python - Efficiently reshape numpy array - Stack Overflow

    I am working with NumPy arrays. I have a 2N length vector D and want to reshape part of it into an N x N array C. Right now this code does what I want, but is a bottleneck for larger N: ``` imp...

  10. python - What is the difference between resize and reshape when …

    Jan 7, 2017 · numpy.resize() ndarray.resize() - where ndarray is an n dimensional array you are resizing. You can similarly call reshape also as numpy.reshape() and ndarray.reshape(). But here …