Shape relates to the size of the dimensions of an N-dimensional array.

Size regarding arrays, relates to the amount (or count) of elements that are contained in the array (or sometimes, at the top dimension of the array - when used as length).

For example, let a be a matrix

1  2  3  4
5  6  7  8
9 10 11 12

the shape of a is (3, 4), the size of a is 12 and the size of a[1] is 4.

Answer from Uriel on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_shape.asp
NumPy Array Shape
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ reference โ€บ generated โ€บ numpy.shape.html
numpy.shape โ€” NumPy v2.5.dev0 Manual
>>> a = np.array([(1, 2), (3, 4), (5, 6)], ... dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (3,) >>> a.shape (3,)
People also ask

How to use shape function in python?
To use the shape function in Python, first import the Pandas library with import pandas as pd and create a DataFrame using df = pd.DataFrame(data). Then, obtain the dimensions as a tuple using dimensions = df.shape. For NumPy arrays, import the NumPy library using import numpy as np, create an array with arr = np.array(data), and get the dimensions with dimensions = arr.shape. The shape function returns a tuple representing the dimensions of the Python data structure.
๐ŸŒ
askpython.com
askpython.com โ€บ home โ€บ python shape function: find dimensions of arrays and dataframes
Python Shape Function: Find Dimensions of Arrays and DataFrames ...
What does shape function do in python?
The shape function in Python is used to find the dimensions of data structures, such as NumPy arrays and Pandas DataFrames. It returns a tuple representing the dimensions, with each tuple element corresponding to the number of elements in that dimension. This function is useful for understanding the structure and size of data objects in Python.
๐ŸŒ
askpython.com
askpython.com โ€บ home โ€บ python shape function: find dimensions of arrays and dataframes
Python Shape Function: Find Dimensions of Arrays and DataFrames ...
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-shape-method
Python shape() method - All you need to know! | DigitalOcean
August 4, 2022 - Yes, it returns a tuple value that indicates the dimensions of a Python object. To understand the output, the tuple returned by the shape() method is the actual number of elements that represent the value of the dimension of the object.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-array-shape
NumPy Array Shape - GeeksforGeeks
July 15, 2025 - Printing the shape of the multidimensional array. In this example, two NumPy arrays arr1 and arr2 are created, representing a 2D array and a 3D array, respectively. The shape of each array is printed, revealing their dimensions and sizes along each dimension.
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ python shape function: find dimensions of arrays and dataframes
Python Shape Function: Find Dimensions of Arrays and DataFrames - AskPython
April 8, 2023 - The shape function in Python yields a tuple that signifies the dimensions of a NumPy array or a Pandas DataFrame. In the case of a DataFrame, the tuple indicates the quantity of rows and columns.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.shape.html
pandas.DataFrame.shape โ€” pandas 3.0.2 documentation
Unlike the len() method, which only returns the number of rows, shape provides both row and column counts, making it a more informative method for understanding dataset size.
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what's the difference between a numpy array with shape (x,) and (x, 1)?
r/learnpython on Reddit: what's the difference between a numpy array with shape (x,) and (x, 1)?
October 6, 2023 -

hey, im doing an ai thing in school and my code didnt work as expected, and after 5 hours i found out i reshaped an array from (206,) to (206,1) and that made the results wrong. and from what i understand, the shape means the length of each dimension, and length is not 0 indexed so a size of 1 would be equal to just 1D no?

๐ŸŒ
Medium
medium.com โ€บ @amit25173 โ€บ numpy-shape-in-python-6cfe7cb20084
numpy.shape in Python. If you think you need to spend $2,000โ€ฆ | by Amit Yadav | Medium
February 9, 2025 - In NumPy, the shape attribute tells you the dimensions of your arrayโ€”whether itโ€™s a single row, a grid of numbers, or something more complex.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ methods โ€บ shape
NumPy shape()
Become a certified Python programmer. Try Programiz PRO! ... The shape() method returns the shape of an array i.e.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.1 โ€บ reference โ€บ generated โ€บ numpy.shape.html
numpy.shape โ€” NumPy v2.1 Manual
>>> a = np.array([(1, 2), (3, 4), (5, 6)], ... dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (3,) >>> a.shape (3,)
๐ŸŒ
Plotly
plotly.com โ€บ python โ€บ shapes
Shapes in Python
Over 30 examples of Shapes including changing color, size, log axes, and more in Python.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ reference โ€บ generated โ€บ numpy.ndarray.shape.html
numpy.ndarray.shape โ€” NumPy v2.5.dev0 Manual
The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.ndarray.shape.html
numpy.ndarray.shape โ€” NumPy v2.4 Manual
The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-shape-attribute-of-numpy-in-python
What is the shape attribute of numpy in Python?
The shape attribute in numpy is used to return a tuple with the index numbers representing the dimension or shape of the given array.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.shape.html
numpy.shape โ€” NumPy v2.4 Manual
>>> a = np.array([(1, 2), (3, 4), (5, 6)], ... dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (3,) >>> a.shape (3,)
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ third-party โ€บ numpy โ€บ shape
Python Numpy shape() - Get Array Dimensions | Vultr Docs
November 19, 2024 - The shape() function in NumPy is an essential tool for managing and manipulating multidimensional arrays. It provides insights into the dimensions of an array, which is crucial when performing array operations that require an understanding of ...
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.2 โ€บ reference โ€บ generated โ€บ numpy.ndarray.shape.html
numpy.ndarray.shape โ€” NumPy v2.2 Manual
The shape property is usually used to get the current shape of an array, but may also be used to reshape the array in-place by assigning a tuple of array dimensions to it. As with numpy.reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-return-the-shape-of-an-array-in-python
How to return the shape of an array in Python
The ma.shape() method in the NumPy module in Python is used to obtain the shape of a given array.