
python - What does .shape [] do in "for i in range (Y.shape [0 ...
shape is a tuple that gives you an indication of the number of dimensions in the array. So in your case, since the index value of Y.shape[0] is 0, your are working along the first dimension of your array.
numpy.shape — NumPy v2.4 Manual
Return the shape of an array. Input array. The elements of the shape tuple give the lengths of the corresponding array dimensions. len(a) is equivalent to np.shape(a)[0] for N-D arrays with N>=1. …
NumPy Shape and Array Dimensions in Python
May 8, 2025 · Understanding NumPy’s shape attribute is essential for efficient data manipulation in Python. I covered the basic usage of NumPy shape, modifying array shape, how to get dimension …
NumPy Array Shape - GeeksforGeeks
Jul 15, 2025 · The shape of an array can be defined as the number of elements in each dimension. Dimension is the number of indices or subscripts, that we require in order to specify an individual …
NumPy Array Shape - W3Schools
NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements. Print the shape of a 2-D array: The example above returns (2, 4), which …
What does shape[0] and shape[1] do in python? - Stack Overflow
Jul 21, 2018 · 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]? Code: m_train = …
numpy.matrix.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.
python - x.shape [0] vs x [0].shape in NumPy - Stack Overflow
Jan 7, 2018 · On the other hand, x.shape is a 2-tuple which represents the shape of x, which in this case is (10, 1024). x.shape[0] gives the first element in that tuple, which is 10. Here's a demo with some …
pandas.DataFrame.shape — pandas 2.3.3 documentation
Return a tuple representing the dimensionality of the DataFrame. Tuple of array dimensions.
Understanding `.shape` in Python - CodeRivers
Jan 24, 2025 · In Python libraries like NumPy, TensorFlow, and PyTorch, the .shape attribute is used to obtain the dimensions of an array or tensor. It returns a tuple of integers, where each integer …