Linked Questions
55 questions linked to/from Difference between numpy.array shape (R, 1) and (R,)
14 votes
2 answers
13k views
What's the difference between (N,) and (N,1) in numpy? [duplicate]
I am not sure about the difference between (N,) and (N,1) in numpy. Assuming both are some features, they have same N dimension, and both have one sample. What's the difference? a = np.ones((10,)) ...
6 votes
2 answers
15k views
For a np.array([1, 2, 3]) why is the shape (3,) instead of (3,1)? [duplicate]
I noticed that for a rank 1 array with 3 elements numpy returns (3,) for the shape. I know that this tuple represents the size of the array along each dimension, but why isn't it (3,1)? import numpy ...
5 votes
3 answers
9k views
Why use arrays of shape (x,) rather than (x,1)? [duplicate]
I've recently encountered a couple of bugs due to numpy arrays being in the shape (x,) - these can easily be fixed by the snippet below a = np.array([1,2,3,4]) #this form produced a bug a.shape >&...
3 votes
2 answers
4k views
numpy: What is the difference between a vector of shape (5,1) and (5,)? [duplicate]
I find that I often have to reshape (5,) into (5,1) in order to use dot product. What can't I just use a dot product with a vector of shape (5,)?
1 vote
2 answers
10k views
only one element in numpy array shape [duplicate]
I have an array converted from list, when I try to get its shape, I got only one number. like this: list1=[1,2,3,4,5] a1=numpy.array(list1) print a1.shape and I got (5,) and then I ...
7 votes
1 answer
6k views
Why Numpy has dimension (n,) instead of (n,1) only [duplicate]
I have been curious about this for some time. I can live with that, but it always bites me when enough care is not taken, so I decide to post it here. Suppose the following example (Numpy version = 1....
4 votes
1 answer
2k views
Difference between numpy.zeros(n) and numpy.zeros(n,1) [duplicate]
What is the difference between numpy.zeros(n) and numpy.zeros(n,1)? The output for the first statement is [0 0 ..... n times] whereas the second one is ([0] [0] .... n rows)
0 votes
1 answer
841 views
Curious of the shape of numpy.linspace [duplicate]
I have this NumPy array: X = numpy.linspace(1, 10, 10) I believe the output will become (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) Why is the shape of this array (10,)? I don't understand why it isn't (1,10).
0 votes
1 answer
588 views
Why does shape return the size (xxxx, ) for my pandas dataframe and not (xxxx, 1)? [duplicate]
I'm using train_test_split with my dataframe, my code looks something like this: df = pd.read_csv('data.csv', header=None) y = df[0] X_train, X_test, y_train, y_test = train_test_split(df, y,...
0 votes
1 answer
312 views
Python - Differences between numpy asarray assignment [duplicate]
What is the difference between train_x = np.asarray([[0.0], [1.0], [2.0], [3.0], [4.0]]) train_y = np.asarray([1.0, 1.1, 3.0, 2.0, 5.0]) in Python numpy.asarray assignment? What is the meaning of [] ...
0 votes
0 answers
66 views
what's the difference between (728,) and (1,728) in numpy shape? [duplicate]
These two seem both array to me. # suppose that test_data has [1000,728] shape print (test_data[0:1,:].shape) # output [1,728] print (test_data[0,:].shape) # output [728,] I tried these two arrays ...
1 vote
1 answer
57 views
Python Numpy coding library [duplicate]
What does this mean in numpy coding, (4,)? You have an array and you run the shape of it and it gives you this answer. What does it mean? x = np.array([1, 2, 3, 4]) x.shape (4,)
0 votes
0 answers
31 views
Numpy arrays of shape (n,) vs. (n,1) - why does this feature exist? (and unexpected addition) [duplicate]
What is the difference between numpy arrays with shapes of form (n,) and (n,1), where n is some number (like 150)? For example, x_dat = np.random.normal(size=150) returns an array of shape (150,), ...
0 votes
0 answers
30 views
Why does numpy array could have shape without column number? [duplicate]
What does (13, ) mean here? without column?
0 votes
0 answers
30 views
In Numpy, what is the difference between an array with shape (4,) and an array with shape (4,1)? [duplicate]
In Numpy, what is the difference between an array with shape (4,) and an array with shape (4,1)? Is it that the latter is a vector?