Array creation routines

See also

Array creation

Ones and zeros

empty
empty_like
eye
identity
ones
ones_like() Returns an array of ones with the same shape and type as a given array.
zeros
zeros_like

From existing data

array
asarray
asanyarray
ascontiguousarray
asmatrix
copy
frombuffer
fromfile
fromfunction
fromiter
fromstring
loadtxt

Creating record arrays (numpy.rec)

Note

numpy.rec is the preferred alias for numpy.core.records.

core.records.array(obj[, dtype, shape, ...]) Construct a record array from a wide-variety of objects.
core.records.fromarrays(arrayList[, dtype, ...]) create a record array from a (flat) list of arrays
core.records.fromrecords(recList[, dtype, ...]) create a recarray from a list of records in text form
core.records.fromstring(datastring[, dtype, ...]) create a (read-only) record array from binary data contained in
core.records.fromfile(fd[, dtype, shape, ...]) Create an array from binary file data

Creating character arrays (numpy.char)

Note

numpy.char is the preferred alias for numpy.core.defchararray.

core.defchararray.array(obj[, itemsize, ...]) Create a chararray.
core.defchararray.asarray(obj[, itemsize, ...]) Convert the input to a chararray, copying the data only if necessary.

Numerical ranges

arange
linspace
logspace
meshgrid
mgrid nd_grid instance which returns a dense multi-dimensional “meshgrid”.
ogrid nd_grid instance which returns an open multi-dimensional “meshgrid”.

Building matrices

diag
diagflat
tri
tril
triu
vander

The Matrix class

mat
bmat