Difference between numpy.array shape (R, 1) and (R,)
We shall now see the difference between the numpy.array shape (R, 1) and (R, ) with the help of given example.
Python3
# importing the NumPy library import numpy as np # creating a 1D array arr_1d = np.array([ 1 , 2 , 3 , 4 ]) # creating a 2D array arr_2d = np.array([[ 1 ],[ 2 ],[ 3 ],[ 4 ]]) print (arr_1d, '\nShape of the array: ' , arr_1d.shape) print () print (arr_2d, '\nShape of the array: ' , arr_2d.shape) |
Output
[1 2 3 4]
Shape of the array: (4,)
[[1]
[2]
[3]
[4]]
Shape of the array: (4, 1)
Here, the shape of the 1D array is (4, ) and the shape of the 2D array is (4, 1).
( R,1 ) |
( R, ) |
---|---|
Shape tuple contains two elements. |
Shape tuple has only one element. |
The 1st element of shape tuple shows the number of rows and the 2nd element shows the number of columns. |
There is only one element and that element shows the number of columns in that array. |
It can have multiple rows. |
It has only one row. |
It has only one column. |
It can have multiple columns. |
The size of the array is R x 1 (Rows x Columns). |
The size of the array is 1 x R (Rows x Columns). |
Array is 2-Dimensional. |
Array is 1-Dimensional. |
Difference between numpy.array shape (R, 1) and (R,)
Difference between numpy.array shape (R, 1) and (R,). In this article, we are going to see the difference between NumPy Array Shape (R,1) and (R,).
Prerequisite: NumPy Array Shape