我是跟着numpy官方中文文档敲的代码,官方中文文档网址为:https://www.numpy.org.cn/user_guide/quickstart_tutorial/deep_copy.html
copy 方法生成数组及其数据的完整拷贝。
>>> d = a.copy()
>>> d
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> d is a
False
>>> d.base is a
False
>>> d[0,0] = 45678
>>> d
array([[45678, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>> a
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
>>>
函数和方法概述
这里是官方文档列出来的一些根据类别排列的有用的NumPy函数和方法名称。
数组创建
arange, array, copy, empty, empty_like, eye, fromfile, fromfunction, identity, linspace, logspace, mgrid, ogrid, ones, ones_like, r, zeros, zeros_like
转换
ndarray.astype, atleast_1d, atleast_2d, atleast_3d, mat
手法
array_split, column_stack, concatenate, diagonal, dsplit, dstack, hsplit, hstack, ndarray.item, newaxis, ravel, repeat, reshape, resize, squeeze, swapaxes, take, transpose, vsplit, vstack
问题
all, any, nonzero, where
顺序
argmax, argmin, argsort, max, min, ptp, searchsorted, sort
操作
choose, compress, cumprod, cumsum, inner, ndarray.fill, imag, prod, put, putmask, real, sum
基本统计
cov, mean, std, var
基本线性代数
cross, dot, outer, linalg.svd, vdot