The reshape() function in Python's NumPy library changes the shape of an array without altering its data, provided the total number of elements remains compatible. You can use numpy.reshape(array, shape, order='C') to specify a new configuration, such as converting a 1D array to 2D or inferring a dimension using -1.

  • Syntax: numpy.reshape(array, shape, order) where shape can be an integer, a tuple, or contain -1 to auto-calculate one dimension.

  • Order: The order argument determines how elements are read and written: 'C' (row-wise), 'F' (column-wise), or 'A' (Fortran-like if contiguous, else C-like).

  • Compatibility: The new shape must have the same total number of elements as the original array, or a ValueError will be raised.

Example usage:

import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
reshaped = np.reshape(arr, (2, 3))  # Converts to 2 rows, 3 columns
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_shape.asp
NumPy Array Shape
NumPy HOME NumPy Intro NumPy Getting Started NumPy Creating Arrays NumPy Array Indexing NumPy Array Slicing NumPy Data Types NumPy Copy vs View NumPy Array Shape NumPy Array Reshape NumPy Array Iterating NumPy Array Join NumPy Array Split NumPy Array Search NumPy Array Sort NumPy Array Filter
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ methods โ€บ reshape
NumPy reshape()
Become a certified Python programmer. Try Programiz PRO! ... The reshape() method changes the shape of a NumPy array without changing its data.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_reshape.asp
NumPy Array Reshaping
By reshaping we can add or remove dimensions or change number of elements in each dimension.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ absolute_beginners.html
NumPy: the absolute basics for beginners โ€” NumPy v2.4 Manual
Using arr.reshape() will give a new shape to an array without changing the data. Just remember that when you use the reshape method, the array you want to produce needs to have the same number of elements as the original array.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ numpy-reshape
Numpy reshape() Function: Python Array Reshaping Guide
January 30, 2024 - Struggling with reshaping arrays in Python? Just like a skilled potter, Numpy's reshape() function allows you to mold your arrays into any shape you desire.
๐ŸŒ
scikit-learn
scikit-learn.org โ€บ stable โ€บ modules โ€บ generated โ€บ sklearn.model_selection.train_test_split.html
train_test_split โ€” scikit-learn 1.8.0 documentation
>>> import numpy as np >>> from sklearn.model_selection import train_test_split >>> X, y = np.arange(10).reshape((5, 2)), range(5) >>> X array([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) >>> list(y) [0, 1, 2, 3, 4]
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.3 โ€บ reference โ€บ generated โ€บ numpy.reshape.html
numpy.reshape โ€” NumPy v2.3 Manual
>>> np.reshape(a, (2, 3)) # C-like index ordering array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering array([[0, 4, 3], [2, 1, 5]]) >>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F') array([[0, 4, 3], [2, 1, 5]])
Find elsewhere
๐ŸŒ
InfoWorld
infoworld.com โ€บ home โ€บ software development โ€บ programming languages โ€บ python
Speed boost your Python programs with new lazy imports | InfoWorld
1 week ago - Python developers typically work around this issue by structuring imports so they donโ€™t happen unless they are neededโ€”for instance, by placing an import in the body of a function instead of at the top level of a module.
๐ŸŒ
Medium
medium.com โ€บ @jennycoreholt โ€บ numpy-reshape-explained-turning-data-into-the-shape-you-need-5406b93653fc
NumPy reshape() Explained: Turning Data Into the Shape You Need | by Jenny Core-Holt | Medium
June 29, 2025 - NumPy reshape() Explained: Turning Data Into the Shape You Need What is np.reshape()? np.reshape() is a method in NumPy that changes the shape (or structure) of an array without changing the data โ€ฆ
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-reshape-python
numpy.reshape() in Python - GeeksforGeeks
January 13, 2025 - In Python, numpy.reshape() function is used to give a new shape to an existing NumPy array without changing its data.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.reshape.html
numpy.reshape โ€” NumPy v2.4 Manual
>>> np.reshape(a, (2, 3)) # C-like index ordering array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering array([[0, 4, 3], [2, 1, 5]]) >>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F') array([[0, 4, 3], [2, 1, 5]])
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ numpy tutorial โ€บ numpy reshape
NumPy reshape | Working of NumPy reshape in Python
April 20, 2023 - The word reshape in python means to change the shape of an array where several elements in every dimension are the meaning of the shape of an array and we make use of NumPy in python to reshape the array meaning to change the number of elements ...
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
M T C News
middletowncafe.com.au โ€บ shocking-revelation-scientists-discover-colossal-african-python-in-the-congo-basin
Shocking Revelation: Scientists Discover Colossal African Python in the Congo Basin! โ€“ M T C News
5 days ago - The discovery of the exceptionally large African python in the Congo Basin represents a major scientific breakthrough, as it challenges previous assumptions about the size and population dynamics of these iconic reptiles. The findings have the potential to reshape our understanding of African python ecology and inform vital conservation efforts in the region.
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ numpy-reshape-function-86496
NumPy Reshape: Python Array Transformation with np.reshape() | LabEx
The reshape() function in the NumPy library allows you to change the shape of an array without altering its data. This powerful function helps you reorganize array elements into different dimensions based on your specific needs.
๐ŸŒ
Real Python
realpython.com โ€บ numpy-reshape
Using NumPy reshape() to Change the Shape of an Array โ€“ Real Python
July 21, 2023 - In this tutorial, you'll learn how to use NumPy reshape() to rearrange the data in an array. You'll learn to increase and decrease the number of dimensions and to configure the data in the new array to suit your requirements.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ reference โ€บ generated โ€บ numpy.reshape.html
numpy.reshape โ€” NumPy v2.5.dev0 Manual
>>> np.reshape(a, (2, 3)) # C-like index ordering array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(np.ravel(a), (2, 3)) # equivalent to C ravel then C reshape array([[0, 1, 2], [3, 4, 5]]) >>> np.reshape(a, (2, 3), order='F') # Fortran-like index ordering array([[0, 4, 3], [2, 1, 5]]) >>> np.reshape(np.ravel(a, order='F'), (2, 3), order='F') array([[0, 4, 3], [2, 1, 5]])
๐ŸŒ
Medium
medium.com โ€บ @machinelearningpy123 โ€บ python-numpy-reshape-function-e304a04a48e7
Python Numpy Reshape Function
August 6, 2023 - As the name suggests, the reshape function is used to change the shape or we can say dimensions but not changing the data of the specified array. It means this function returns an array of the same data but a different shape.