Numpy matrices are strictly 2-dimensional, while numpy arrays (ndarrays) are N-dimensional. Matrix objects are a subclass of ndarray, so they inherit all the attributes and methods of ndarrays.

The main advantage of numpy matrices is that they provide a convenient notation for matrix multiplication: if a and b are matrices, then a*b is their matrix product.

import numpy as np

a = np.mat('4 3; 2 1')
b = np.mat('1 2; 3 4')
print(a)
# [[4 3]
#  [2 1]]
print(b)
# [[1 2]
#  [3 4]]
print(a*b)
# [[13 20]
#  [ 5  8]]

On the other hand, as of Python 3.5, NumPy supports infix matrix multiplication using the @ operator, so you can achieve the same convenience of matrix multiplication with ndarrays in Python >= 3.5.

import numpy as np

a = np.array([[4, 3], [2, 1]])
b = np.array([[1, 2], [3, 4]])
print(a@b)
# [[13 20]
#  [ 5  8]]

Both matrix objects and ndarrays have .T to return the transpose, but matrix objects also have .H for the conjugate transpose, and .I for the inverse.

In contrast, numpy arrays consistently abide by the rule that operations are applied element-wise (except for the new @ operator). Thus, if a and b are numpy arrays, then a*b is the array formed by multiplying the components element-wise:

c = np.array([[4, 3], [2, 1]])
d = np.array([[1, 2], [3, 4]])
print(c*d)
# [[4 6]
#  [6 4]]

To obtain the result of matrix multiplication, you use np.dot (or @ in Python >= 3.5, as shown above):

print(np.dot(c,d))
# [[13 20]
#  [ 5  8]]

The ** operator also behaves differently:

print(a**2)
# [[22 15]
#  [10  7]]
print(c**2)
# [[16  9]
#  [ 4  1]]

Since a is a matrix, a**2 returns the matrix product a*a. Since c is an ndarray, c**2 returns an ndarray with each component squared element-wise.

There are other technical differences between matrix objects and ndarrays (having to do with np.ravel, item selection and sequence behavior).

The main advantage of numpy arrays is that they are more general than 2-dimensional matrices. What happens when you want a 3-dimensional array? Then you have to use an ndarray, not a matrix object. Thus, learning to use matrix objects is more work -- you have to learn matrix object operations, and ndarray operations.

Writing a program that mixes both matrices and arrays makes your life difficult because you have to keep track of what type of object your variables are, lest multiplication return something you don't expect.

In contrast, if you stick solely with ndarrays, then you can do everything matrix objects can do, and more, except with slightly different functions/notation.

If you are willing to give up the visual appeal of NumPy matrix product notation (which can be achieved almost as elegantly with ndarrays in Python >= 3.5), then I think NumPy arrays are definitely the way to go.

PS. Of course, you really don't have to choose one at the expense of the other, since np.asmatrix and np.asarray allow you to convert one to the other (as long as the array is 2-dimensional).


There is a synopsis of the differences between NumPy arrays vs NumPy matrixes here.

Answer from unutbu on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.array.html
numpy.array — NumPy v2.5 Manual
>>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')]) >>> x['a'] array([1, 3], dtype=int32)
🌐
W3Schools
w3schools.com › python › NumPy › numpy_creating_arrays.asp
NumPy Creating Arrays
Use a tuple to create a NumPy array: import numpy as np arr = np.array((1, 2, 3, 4, 5)) print(arr) Try it Yourself » · A dimension in arrays is one level of array depth (nested arrays). nested array: are arrays that have arrays as their elements. 0-D arrays, or Scalars, are the elements in an array.
🌐
NumPy
numpy.org › doc › stable › user › absolute_beginners.html
NumPy: the absolute basics for beginners — NumPy v2.5 Manual
The NumPy library contains multidimensional array data structures, such as the homogeneous, N-dimensional ndarray, and a large library of functions that operate efficiently on these data structures. Learn more about NumPy at What is NumPy, and if you have comments or suggestions, please reach out!
🌐
GeeksforGeeks
geeksforgeeks.org › python › basics-of-numpy-arrays
Basics of NumPy Arrays - GeeksforGeeks
June 16, 2026 - Example: The following example creates a one-dimensional NumPy array from a Python list. ... import numpy as np a = [1, 2, 3, 4] arr = np.array(a) print("List: ", a) print("Numpy Array:", arr) print(type(a)) print(type(arr))
🌐
NumPy
numpy.org
NumPy
Powerful N-dimensional arrays Fast and versatile, the NumPy vectorization, indexing, and broadcasting concepts are the de-facto standards of array computing today. Numerical computing tools NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more.
Top answer
1 of 7
487

Numpy matrices are strictly 2-dimensional, while numpy arrays (ndarrays) are N-dimensional. Matrix objects are a subclass of ndarray, so they inherit all the attributes and methods of ndarrays.

The main advantage of numpy matrices is that they provide a convenient notation for matrix multiplication: if a and b are matrices, then a*b is their matrix product.

import numpy as np

a = np.mat('4 3; 2 1')
b = np.mat('1 2; 3 4')
print(a)
# [[4 3]
#  [2 1]]
print(b)
# [[1 2]
#  [3 4]]
print(a*b)
# [[13 20]
#  [ 5  8]]

On the other hand, as of Python 3.5, NumPy supports infix matrix multiplication using the @ operator, so you can achieve the same convenience of matrix multiplication with ndarrays in Python >= 3.5.

import numpy as np

a = np.array([[4, 3], [2, 1]])
b = np.array([[1, 2], [3, 4]])
print(a@b)
# [[13 20]
#  [ 5  8]]

Both matrix objects and ndarrays have .T to return the transpose, but matrix objects also have .H for the conjugate transpose, and .I for the inverse.

In contrast, numpy arrays consistently abide by the rule that operations are applied element-wise (except for the new @ operator). Thus, if a and b are numpy arrays, then a*b is the array formed by multiplying the components element-wise:

c = np.array([[4, 3], [2, 1]])
d = np.array([[1, 2], [3, 4]])
print(c*d)
# [[4 6]
#  [6 4]]

To obtain the result of matrix multiplication, you use np.dot (or @ in Python >= 3.5, as shown above):

print(np.dot(c,d))
# [[13 20]
#  [ 5  8]]

The ** operator also behaves differently:

print(a**2)
# [[22 15]
#  [10  7]]
print(c**2)
# [[16  9]
#  [ 4  1]]

Since a is a matrix, a**2 returns the matrix product a*a. Since c is an ndarray, c**2 returns an ndarray with each component squared element-wise.

There are other technical differences between matrix objects and ndarrays (having to do with np.ravel, item selection and sequence behavior).

The main advantage of numpy arrays is that they are more general than 2-dimensional matrices. What happens when you want a 3-dimensional array? Then you have to use an ndarray, not a matrix object. Thus, learning to use matrix objects is more work -- you have to learn matrix object operations, and ndarray operations.

Writing a program that mixes both matrices and arrays makes your life difficult because you have to keep track of what type of object your variables are, lest multiplication return something you don't expect.

In contrast, if you stick solely with ndarrays, then you can do everything matrix objects can do, and more, except with slightly different functions/notation.

If you are willing to give up the visual appeal of NumPy matrix product notation (which can be achieved almost as elegantly with ndarrays in Python >= 3.5), then I think NumPy arrays are definitely the way to go.

PS. Of course, you really don't have to choose one at the expense of the other, since np.asmatrix and np.asarray allow you to convert one to the other (as long as the array is 2-dimensional).


There is a synopsis of the differences between NumPy arrays vs NumPy matrixes here.

2 of 7
107

Scipy.org recommends that you use arrays:

*'array' or 'matrix'? Which should I use? - Short answer

Use arrays.

  • They support multidimensional array algebra that is supported in MATLAB
  • They are the standard vector/matrix/tensor type of NumPy. Many NumPy functions return arrays, not matrices.
  • There is a clear distinction between element-wise operations and linear algebra operations.
  • You can have standard vectors or row/column vectors if you like.

Until Python 3.5 the only disadvantage of using the array type was that you had to use dot instead of * to multiply (reduce) two tensors (scalar product, matrix vector multiplication etc.). Since Python 3.5 you can use the matrix multiplication @ operator.

Given the above, we intend to deprecate matrix eventually.

Find elsewhere
🌐
Earth Data Science
earthdatascience.org › home
Intro to Numpy Arrays | Earth Data Science - Earth Lab
September 23, 2019 - Numpy arrays are a commonly used scientific data structure in Python that store data as a grid, or a matrix. Learn about the key characteristics of numpy arrays that make them an efficient data structure for storing and working with large scientific datasets.
🌐
New York University
physics.nyu.edu › pine › pymanual › html › chap3 › chap3_arrays.html
3. Strings, Lists, Arrays, and Dictionaries — PyMan 0.9.31 documentation
The most import data structure for scientific computing in Python is the NumPy array. NumPy arrays are used to store lists of numerical data and to represent vectors, matrices, and even tensors. NumPy arrays are designed to handle large data sets efficiently and with a minimum of fuss.
🌐
DataCamp
datacamp.com › doc › numpy › array
NumPy array()
It allows for efficient storage and manipulation of numerical data, making it essential for scientific and mathematical computing. The np.array() function is used to convert Python lists, tuples, other array-like objects such as existing NumPy arrays, or any similar structures into NumPy arrays.
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › numpy-array-functions
NumPy Array Functions - GeeksforGeeks
July 23, 2025 - This article explores some of the most important NumPy array functions with examples to help you harness their power. np.array(): Converts a Python list, tuple, or sequence into an array.
🌐
NumPy
numpy.org › doc › stable › reference › arrays.ndarray.html
The N-dimensional array (ndarray) — NumPy v2.5 Manual
A 2-dimensional array of size 2 x 3, composed of 4-byte integer elements: ... >>> x = np.array([[1, 2, 3], [4, 5, 6]], np.int32) >>> type(x) <class 'numpy.ndarray'> >>> x.shape (2, 3) >>> x.dtype dtype('int32')
🌐
Molssi
education.molssi.org › python-data-analysis › 01-numpy-arrays › index.html
Working with Numpy Arrays – Python for Data Analysis
April 17, 2022 - There are also differences in how lists and numpy arrays behave. Let’s look at some of these. First open a Jupyter notebook to record your work. To use the numpy library, we have to import it. When numpy is imported, it is often shortened to np as shown below:
🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter02.07-Introducing_numpy_arrays.html
Introducing Numpy Arrays — Python Numerical Methods
WARNING! Of course, you could call it any name, but conventionally, “np” is accepted by the whole community and it is a good practice to use it for obvious purposes. To define an array in Python, you could use the np.array function to convert a list.
🌐
NumPy
numpy.org › doc › 2.1 › reference › arrays.html
Array objects — NumPy v2.1 Manual
NumPy provides an N-dimensional array type, the ndarray, which describes a collection of “items” of the same type.
🌐
Mattermost
mattermost.com › home › beginner’s guide to numpy
Beginner’s Guide to NumPy - Mattermost
September 13, 2022 - In the following code, we’re creating a simple NumPy array containing integer values. import numpy as np myArray = np.array([1, 2, 3, 4, 5, 6]) print(myArray)
🌐
Reddit
reddit.com › r/learnpython › what is np.arrays??
r/learnpython on Reddit: what is np.arrays??
April 12, 2025 -

Hi all, so when working with co-ordinates when creating maths animations using a library called manim, a lot of the code uses np.array([x,y,z]). why dont they just use normal (x,y,z) co-ordinates. what is an array?

thanks in advance

Top answer
1 of 5
12
np is a common alias for the numpy library. It uses "arrays" rather than lists because that's what they're called in lower-level languages like C. There are differences, but they're trivial for this conversation. Numpy uses one of these lower-level languages (rather than pure Python) to optimize their operations. In short, Python lists are designed to be flexible, not efficient; numpy.arrays are designed to be efficient, but not as flexible. Your manim library probably has to do a lot of math, many times, really fast, so optimizing that math with numpy arrays makes a little more sense than using the more user-friendly builtin lists.
2 of 5
5
To add to member_of_the_order's answer, let's do an example. Say you have a vector that goes from origin to the coords of (8,3,7) and you want to scale it. coords = (8,3,7) print(coords * 2) print(coords * 0.5) Output: (8, 3, 7, 8, 3, 7) Traceback (most recent call last): [...] TypeError: can't multiply sequence by non-int of type 'float' Well that's not what we want! First it just repeated the tuple instead of scaling it and then it threw an error instead of scaling it! Instead we have to iterate over each entry: coords =(8,3,7) scaled_double = [] scaled_half = [] for coord in coords: scaled_double.append(coord*2) scaled_half.append(coord*0.5) print(scaled_double) print(scaled_half) This is awkward, and more importantly it is slow. Looping over things in Python is a slow operation when it is a big loop. In numpy, we would simply do: import numpy as np coords = (8,3,7) vec = np.array(coords) print(vec * 2) print(vec * 0.5) Because of how slow python is at looping, this is much more efficient when coords has more entries in it: mport numpy as np import time coords = (8,3,7) * 1000000 vec = np.array(coords) scaled_double = [] scaled_half = [] start_python = time.time() for coord in coords: scaled_double.append(coord*2) scaled_half.append(coord*0.5) end_python = time.time() start_numpy = time.time() vector_doubled = vec * 2 vector_halved = vec * 0.5 end_numpy = time.time() print(end_python-start_python) print(end_numpy-start_numpy) 0.7611937522888184 0.02443075180053711
🌐
Jmgphd
jmgphd.com › courses › csc5930 › lecture-notes › numpy-arrays
NumPy Arrays – Jason M. Grant
The first method for creating a new array is to specify all of the elements of the array directly. Below are examples of one-dimensional and two-dimensional arrays. arr1 = np.array([1,3,5,7,9]) arr2 = np.array([[1.0,3.1,5.2,7.1,9.8],[2.1,4.3,6.5,8.7,10.9]])
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.array.html
numpy.array — NumPy v2.1 Manual
When order is ‘A’ and object is an array in neither ‘C’ nor ‘F’ order, and a copy is forced by a change in dtype, then the order of the result is not necessarily ‘C’ as expected. This is likely a bug. Examples · >>> import numpy as np >>> np.array([1, 2, 3]) array([1, 2, 3]) Upcasting: >>> np.array([1, 2, 3.0]) array([ 1., 2., 3.]) More than one dimension: >>> np.array([[1, 2], [3, 4]]) array([[1, 2], [3, 4]]) Minimum dimensions 2: >>> np.array([1, 2, 3], ndmin=2) array([[1, 2, 3]]) Type provided: >>> np.array([1, 2, 3], dtype=complex) array([ 1.+0.j, 2.+0.j, 3.+0.j]) Data-typ
🌐
Medium
medium.com › @aamernabi › a-deep-dive-into-numpy-arrays-77753e3a8bf5
A Deep Dive into NumPy arrays
March 9, 2024 - NumPy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of non-negative integers. Before getting started, make sure you are using Python v3.+ on your ...