(3,) does not mean the 3 is first. It is simply the Python way of writing a 1-element tuple. If the shape were a list instead, it would be [3].

(, 3) is not valid Python. The syntax for a 1-element tuple is (element,).

The reason it can't be just (3) is that Python simply views the parentheses as a grouping construct, meaning (3) is interpreted as 3, an integer.

Answer from iz_ on Stack Overflow
🌐
DeepLearning.AI
community.deeplearning.ai › course q&a › machine learning specialization › advanced learning algorithms › difference between .shape[0] and .shape[1]
Difference between .shape[0] and .shape[1] - Advanced Learning Algorithms - DeepLearning.AI
August 27, 2022 - Hi, In the course, i find sometimes the code is written as m=X.shape[0] and n=w.shape[1]. Can you tell me the difference between these 2 functions, .shape[0] and .shape[1], though both returns the number of columns in an array
🌐
Python Guides
pythonguides.com › python-numpy-shape
NumPy Shape in Python: shape[0] and shape[1]
May 8, 2025 - This is the part that sends people to search engines. For a 2D array, shape[0] is the number of rows and shape[1] is the number of columns:
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 - Shape 1 of numpy array - Stack Overflow
In Python's view, x has shape (4, ... didn't Python view v as having shape (, 3). Also, why do v and v.T have the same shape (3, ). IMHO, I think if v has shape (3, ) then v.T should have shape (, 3)? ... There are two issues - the proper notation for a tuple (shape is a tuple), and what does it mean to be 1 ... More on stackoverflow.com
🌐 stackoverflow.com
python - What does .shape[] do in "for i in range(Y.shape[0])"? - Stack Overflow
and http://www.scipy.org/Numpy_Example_List#shape has some more examples. ... @HipsterCarlGoldstein Just a friendly note, if any one of these answers provided solved your problem please consider accepting it by clicking the checkmark next to the answer. This will give you and the answerer both some rep points and also mark this problem as solved - thanks. 2012-06-17T19:31:08.767Z+00:00 ... Save this answer. ... Show activity on this post. In python... More on stackoverflow.com
🌐 stackoverflow.com
February 3, 2021
What does shape[0] and shape[1] do in python? - Stack Overflow
In python shape[0] returns the dimension but in this code it is returning total number of set. Please can someone tell me work of shape[0] and shape[1]? More on stackoverflow.com
🌐 stackoverflow.com
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.shape.html
numpy.shape — NumPy v2.6.dev0 Manual
Return the shape of an array · The elements of the shape tuple give the lengths of the corresponding array dimensions
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-shape-method
Python shape() method - All you need to know! | DigitalOcean
August 4, 2022 - Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
GeeksforGeeks
geeksforgeeks.org › python › difference-between-numpy-array-shape-r-1-and-r
Difference between numpy.array shape (R, 1) and (R,) - GeeksforGeeks
July 23, 2025 - (R, ) is a shape tuple of the 1-D array in Python. This shape tuple shows the number of columns in the 1-D array, i.e., the number of elements in that array.
🌐
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
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_shape.asp
NumPy Array Shape
The shape of an array is the number of elements in each dimension.
🌐
Medium
medium.com › @amit25173 › understanding-numpy-shape-6fbb6b83891e
Understanding numpy.shape. If you think you need to spend $2,000… | by Amit Yadav | Medium
February 9, 2025 - What happens if you try to access an index beyond the shape? This might surprise you: if you try to access a dimension that doesn’t exist, NumPy won’t quietly ignore it — it’ll throw an error! It’s like asking for a third floor in a building that only has two. ... # A 1D array array = np.array([1, 2, 3]) # Trying to access a nonexistent dimension print(array.shape[1]) # This will raise an error
🌐
PyPI
pypi.org › project › shape
shape · PyPI
shape is a Python package for 2D shapes handling. objects: abstract shape · point · polygon · bounding box · rotated bounding box · ellipse · relations: intersection, closeness · manipulation: move and rotate · visualization using matplotlib ...
🌐
AskPython
askpython.com › python-modules › pandas › shape-method
Python Shape Function: Find Dimensions of Arrays and DataFrames - AskPython
July 6, 2021 - 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.
🌐
PyMC Discourse
discourse.pymc.io › questions › v5
Difference between shape = (2,1) & shape = 2 - v5 - PyMC Discourse
September 29, 2023 - Hi, Recently, I felt something very weird here. I am doing some toy examples for code verification. Here, I believed that two models should return the same results. But, the only second model returns me correct results (the first model gives me posterior distributions around 0)… The only difference between two models are whether I implied shape as a vector or int.
🌐
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 - Let’s dive into some practical uses of shape. ... Imagine you’re given a long list of numbers, but you need them organized neatly into rows and columns. That’s where reshape() comes in. It lets you rearrange the data while keeping all elements intact. ... import numpy as np # Reshaping a 1D array into a 2D array array = np.array([1, 2, 3, 4, 5, 6]) print("Original array:", array) print("Original shape:", array.shape) # Reshape the array to 2 rows and 3 columns reshaped_array = array.reshape(2, 3) print("\nReshaped array:\n", reshaped_array) print("New shape:", reshaped_array.shape)
🌐
Medium
medium.com › data-science › get-into-shape-14637fe1cd32
Get into shape! 🐍
April 16, 2021 - It’s easy to get the number of dimensions and size form the shape attribute so that’s the one to remember and the one we’ll use. 🚀 · Let’s make a pandas Series from our DataFrame. Use just the brackets syntax to select a column by passing the name of the column as a string. You get back a Series. years_series = df_hurricanes['year'] years_series0 2020 1 1992 2 1972 Name: year, dtype: int64type(years_series)pandas.core.series.Series
🌐
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 ...
🌐
Programiz
programiz.com › python-programming › numpy › methods › shape
NumPy shape() | Programiz
August 30, 2023 - The shape() method returns the shape of an array i.e. the number of elements in each dimension. import numpy as np array = np.array([[0, 1], [2, 3]])
🌐
YouTube
youtube.com › aaron maxwell
Python: NumPy Shape and Dimensions - YouTube
This video was produced by West Virginia View (http://www.wvview.org/) with support from AmericaView (https://americaview.org/). This material is based upon
Published: April 24, 2022
Views: 651