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,)
Discussions

what's the difference between a numpy array with shape (x,) and (x, 1)?
import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(arr.shape) # Output: (5,) arr = np.array([[1], [2], [3], [4], [5]]) print(arr.shape) # Output: (5, 1) arr = np.array([[1, 2, 3, 4, 5]]) print(arr.shape) # Output: (1, 5) More on reddit.com
🌐 r/learnpython
6
1
October 6, 2023
python - numpy: "size" vs. "shape" in function arguments? - Stack Overflow
I noticed that some numpy operations take an argument called shape, such as np.zeros, whereas some others take an argument called size, such as np.random.randint. To me, those arguments have the same More on stackoverflow.com
🌐 stackoverflow.com
Question about .shape in python

The shape method returns a number for each dimension of the array, that can be 1 for vectors, 2 for matrices and it can be even more.

Look at these:

>>> np.array([1,2,3]).shape
(3,)
>>> np.array([[1,2,3]]).shape
(1, 3)
>>> np.array([[1],[2],[3]]).shape
(3, 1)
>>> np.array([[[1],[2],[3]]]).shape
(1, 3, 1)
>>> np.array([[1,2], [3,4]]).shape
(2, 2)
>>> np.array([[[1],[2]], [[3],[4]]]).shape
(2, 2, 1)
More on reddit.com
🌐 r/AskProgramming
7
1
February 16, 2022
What are the different methods to find the shape of a Numpy array? - Python - Data Science Dojo Discussions
To determine the shape of a NumPy array, you can utilize the shape attribute, which provides a tuple representing the number of rows and columns. For instance, a 3x4 array will yield a shape of (3, 4). The shape attribute is essential for understanding array dimensions and enabling diverse ... More on discuss.datasciencedojo.com
🌐 discuss.datasciencedojo.com
3
0
November 9, 2022
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.
🌐
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?

Find elsewhere
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.shape.html
pandas.DataFrame.shape — pandas 3.0.1 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.
🌐
Reddit
reddit.com › r › AskProgramming › comments › su2fky › question_about_shape_in_python
r/AskProgramming - Question about .shape in python
February 16, 2022 -

I'm doing a project where I gotta do dot product without .dot and such for vectors and matrices, I am using .shape to get back the number of rows and columns for a matrix/vector. I got an error that said valueerror: not enough values to unpack(expected 2, got 1) at the line where I try to get the rows and columns: it's like rows, columns = a.shape. my professor said this happens because when a is a vector and not a matrix it only returns 1 value, but from what I can see online it returns 2 even if it's a vector? Should .shape not just return the number of rows and columns regardless?

🌐
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.
🌐
Zod
zod.dev
Intro | Zod
Introduction to Zod - TypeScript-first schema validation library with static type inference
🌐
PyPI
pypi.org › project › pyshp
pyshp · PyPI
The Python Shapefile Library (PyShp) provides read and write support for the Esri Shapefile format. The Shapefile format is a popular Geographic Information System vector data format created by Esri.
      » pip install pyshp
    
Published   Nov 28, 2025
Version   3.0.3
🌐
Interactive Chaos
interactivechaos.com › en › python › function › ndarrayshape
ndarray.shape | Interactive Chaos
January 21, 2019 - Python scenarios · Full name · ndarray.shape · Library · NumPy · Syntax · ndarray.shape · Description · The numpy.ndarray.shape attribute returns a tuple with the size of the array, but can also be used to resize it.
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_array_shape.htm
NumPy - Array Shape
The shape of a NumPy array is a tuple of integers. Each integer in the tuple represents the size of the array along a particular dimension or axis. For example, an array with shape (3, 4) has 3 rows and 4 columns.
🌐
Hugging Face
huggingface.co › google › gemma-3-27b-it
google/gemma-3-27b-it · Hugging Face
messages = [ { "role": "system", "content": [{"type": "text", "text": "You are a helpful assistant."}] }, { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] } ] output = pipe(text=messages, max_new_tokens=200) print(output[0]["generated_text"][-1]["content"]) # Okay, let's take a look! # Based on the image, the animal on the candy is a **turtle**. # You can see the shell shape and the head and legs.
🌐
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,)
🌐
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.
🌐
Python Guides
pythonguides.com › python-numpy-shape
NumPy Shape And Array Dimensions In Python
May 16, 2025 - Learn how to use NumPy shape in Python to understand and manipulate array dimensions. Examples with real-world data, reshaping techniques, and common solutions.
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
What are the different methods to find the shape of a Numpy array? - Python - Data Science Dojo Discussions
November 9, 2022 - To determine the shape of a NumPy array, you can utilize the shape attribute, which provides a tuple representing the number of rows and columns. For instance, a 3x4 array will yield a shape of (3, 4). The shape attribute is essential for ...
🌐
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 ...
🌐
Codecademy
codecademy.com › docs › python:numpy › ndarray › .shape
Python:NumPy | ndarray | .shape | Codecademy
October 30, 2025 - The .shape attribute of a NumPy ndarray returns a tuple of integers specifying the size of the array in each dimension. It provides information about the structure and layout of the array.