Numpy 创建数组

创建数组

方法描述
empty(shape[, dtype, order])根据指定的shape和dtype创建数组
empty_like(a[, dtype, order, subok])根据已知数组的shape和dtype创建数组
eye(N[, M, k, dtype, order])创建对角线为1的二维数组
identity(n[, dtype])创建单位阵
ones(shape[, dtype, order])根据指定shape创建全为1的数组
ones_like(a[, dtype, order, subok])根据已知数组的shape创建全为1的数组
zeros(shape[, dtype, order])创建全部为0的数组
zeros_like(a[, dtype, order, subok])根据已知的数组创建全为0的数组
full(shape, fill_value[, dtype, order])根据shape,fill_value创建数组
full_like(a, fill_value[, dtype, order, subok])根据已知数组的shape创建权威fill_value的数组

从已有数据中创建数组

方法描述
array(object[, dtype, copy, order, subok, ndmin])创建一个数组,参数为list
asarray(a[, dtype, order])Convert the input to an array.
asanyarray(a[, dtype, order])Convert the input to an ndarray, but pass ndarray subclasses through.
ascontiguousarray(a[, dtype])Return a contiguous array in memory (C order).
asmatrix(data[, dtype])Interpret the input as a matrix.
copy(a[, order])Return an array copy of the given object.
frombuffer(buffer[, dtype, count, offset])Interpret a buffer as a 1-dimensional array.
fromfile(file[, dtype, count, sep])Construct an array from data in a text or binary file.
fromfunction(function, shape, **kwargs)Construct an array by executing a function over each coordinate.
fromiter(iterable, dtype[, count])Create a new 1-dimensional array from an iterable object.
fromstring(string[, dtype, count, sep])从字符串中创建一维数组
loadtxt(fname[, dtype, comments, delimiter, …])Load data from a text file.

Numerical ranges

方法描述
arange([start,] stop[, step,][, dtype])Return evenly spaced values within a given interval.
linspace(start, stop[, num, endpoint, …])Return evenly spaced numbers over a specified interval.
logspace(start, stop[, num, endpoint, base, …])Return numbers spaced evenly on a log scale.
geomspace(start, stop[, num, endpoint, dtype])Return numbers spaced evenly on a log scale (a geometric progression).
meshgrid(*xi, **kwargs)Return coordinate matrices from coordinate vectors.
mgridnd_grid instance which returns a dense multi-dimensional “meshgrid”.
ogridnd_grid instance which returns an open multi-dimensional “meshgrid”.

创建矩阵

方法描述
diag(v[, k])提取或创建对角矩阵
diagflat(v[, k])Create a two-dimensional array with the flattened input as a diagonal.
tri(N[, M, k, dtype])An array with ones at and below the given diagonal and zeros elsewhere.
tril(m[, k])Lower triangle of an array.
triu(m[, k])Upper triangle of an array.
vander(x[, N, increasing])Generate a Vandermonde matrix.

创建矩阵对象

方法描述
mat(data[, dtype])Interpret the input as a matrix.
bmat(obj[, ldict, gdict])Build a matrix object from a string, nested sequence, or array.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值