Like all packages, you can import parts of NumPy or the entire package. However, there’s a convention to import the entire package and rename it to
np. The simple reason for this is that most NumPy users use the package interactively. It helps us type less and not worry about importing things whenever we need a new NumPy feature.
In addition, many examples on the web will use this convention of renaming to
np. You’ll make your work a lot easier by abiding by it as well.
To use this convention as well, you can import NumPy as follows:
import numpy as np
Throughout this course, we assume you have NumPy imported as
np so we don’t have to repeat that step in every code example.