NumPy eig - How to calculate the eigenvalues and eigenvectors of a matrix in Python

Eigenvalues and eigenvectors can be calculated using numpy.linalg.eig.

import numpy

a = numpy.array([[3, 2], [1, 4]])
b = numpy.linalg.eig(a)

print(type(b))  # <class 'tuple'>

values, vectors = numpy.linalg.eig(a)

print(values)
# [2. 5.]

print(vectors)
# [[-0.89442719 -0.70710678]
#  [ 0.4472136  -0.70710678]]

linalg is a famous module and eig returns a tuple of eigenvalues and eigenvectors.

NumPy Matrix

NumPy Tutorial