NumPy Commands

Importing NumPy

Before any of the following commands are used, the NumPy library must be imported into Sage. This is done with the command

import numpy

You may also assign numpy a different name for convenience, such as np, using as:

import numpy as np

After importation, any numpy commands must be preceded by the name of the import and a dot operator like so: np.array()

NumPy Commands

This section assumes a basic knowledge of Python 2.

N-Dimensional Arrays

Basic commands for NumPy's core function, the ndarray object.


Boolean Logic in NumPy

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License