user697911
user697911

Reputation: 10531

Numpy array dimension

In [21]: a = np.array([1,2,3])

In [22]: a.shape
Out[22]: (3,)

What's the difference between (3,) and (3,1) in shape?

Why isn't the output (,3) or (1,3)? This is a 1 by 3 matrix, right?

Upvotes: 1

Views: 67

Answers (1)

BrenBarn
BrenBarn

Reputation: 251365

No. A 1x3 matrix would be a two-dimensional array (e.g., np.array([[1, 2, 3]])). What you have is a one-dimensional array of length three. In mathematical terms, a 1D array roughly corresponds to a vector.

Upvotes: 2

Related Questions