随笔分类 -  Numpy

摘要:描述: 百分位数表示小于这个值的观察值的百分比。 numpy.percentile(a, q, axis) 参数: a:输入数组。 q:计算的百分位数,在 0100 之间。 axis:沿着它计算百分位数的轴。 interpolation:str,用于估计百分位数的方法。默认 $linear 阅读全文
posted @ 2022-12-08 14:24 做梦当财神 阅读(906) 评论(0) 推荐(0) 编辑
摘要:1. 广播的引出 numpy 两个数组相加、相减、相乘都是对应元素之间的操作。 示例:numpy 数组相乘。 import numpy as np x = np.array([[2,2,3],[1,2,3]]) y = np.array([[1,1,3],[2,2,4]]) print(x* 阅读全文
posted @ 2022-09-13 22:50 做梦当财神 阅读(266) 评论(0) 推荐(0) 编辑
摘要:1. FFT 知识 傅里叶变换(Fourier Transform,FT) 是一种线性积分变换,用于信号在时域(或空域)到频域之间的变换。 FFT变换(Fast Fourier Transform) 是针对一组数值进行运算,这组数的长度 N 必须是 2 的整 阅读全文
posted @ 2022-08-29 13:30 做梦当财神 阅读(1189) 评论(0) 推荐(0) 编辑
摘要:numpy.prod(a, axis=None, dtype=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>):返回给定轴上数组元素的乘积。 参数: a:输入数据。 axis:无或整数或整数元组,可选 阅读全文
posted @ 2022-08-26 11:49 做梦当财神 阅读(276) 评论(0) 推荐(0) 编辑
摘要:np.sum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue) 参数: a:用于进行加法运算的数组形式的元素。 axis:axis 的取值有三种情况:1.None,2.整数, 3.整数元组。(在默认/缺省的情况下,axis 阅读全文
posted @ 2022-08-24 11:28 做梦当财神 阅读(506) 评论(0) 推荐(0) 编辑
摘要:np.reshape():在不改变数据的条件下修改形状。 numpy.reshape(arr, newshape, order='C') 参数: arr:要修改形状的数组 newshape:整数或者整数数组,新的形状应当兼容原有形状 order:'C' -- 按行,'F' -- 按列,'A' -- 阅读全文
posted @ 2022-08-24 11:27 做梦当财神 阅读(1069) 评论(0) 推荐(0) 编辑
摘要:np.squeeze:从数组的形状中删除维度为 1 的维度。 np.squeeze(arr, axis) 参数: arr:输入数组 axis:整数或整数元组,用于选择形状中一维维度的子集。 示例: import numpy as np x = np.arange(9).reshape(1, 3, 阅读全文
posted @ 2022-08-24 11:25 做梦当财神 阅读(718) 评论(0) 推荐(0) 编辑
摘要:1. 生成数组所需格式不同 np.mat()可以从字符串或列表中生成。np.array()只能从列表中生成。 import numpy as np a = np.mat(data="1, 2; 3, 4") b = np.array([[1, 2], [3, 4]]) print(a) print( 阅读全文
posted @ 2021-10-20 15:34 做梦当财神 阅读(437) 评论(0) 推荐(0) 编辑
摘要:np.nonzero() 函数返回输入数组中非零元素的索引。 import numpy as np a = np.array([[30, 40, 0], [0, 20, 10], [50, 0, 60]]) print(a) print(np.nonzero(a)) 输出结果: [[30 40 0] 阅读全文
posted @ 2021-10-20 13:46 做梦当财神 阅读(139) 评论(0) 推荐(0) 编辑
摘要:计算矩阵的乘积。 numpy.dot(a, b, out=None) 参数: a:数组 b:数组 out:可选,保存 dot() 计算结果 实例: import numpy as np a = np.array([[1,2],[3,4]]) b = np.array([[11,12],[13,14] 阅读全文
posted @ 2021-10-12 13:35 做梦当财神 阅读(241) 评论(0) 推荐(0) 编辑
摘要:一、定义 np.concatenate() :连接沿现有轴的数组。 函数用于沿指定轴连接相同形状的两个或多个数组。 np.concatenate((a1, a2, ...), axis) 参数: a1, a2, ...:相同类型的数组 axis: 沿着它连接数组的轴,默认为0 实例: import 阅读全文
posted @ 2021-10-08 21:57 做梦当财神 阅读(326) 评论(0) 推荐(0) 编辑
摘要:np.expend_dims :扩展数组形状。 通过在指定位置插入新的轴来扩展数组形状。 np.expand_dims(arr, axis) 参数: arr:输入数组 axis:新轴插入的位置 实例: import numpy as np x = np.array(([1, 2], [3, 4])) 阅读全文
posted @ 2021-10-08 21:40 做梦当财神 阅读(1007) 评论(0) 推荐(0) 编辑
摘要:numpy.unique:用于去除数组中重复元素,并从小到大排序。 numpy.unique(arr, return_index, return_inverse, return_counts) arr:输入数组,如果不是一维数组则会展开 return_index:如果为true,返回新列表元素在旧列 阅读全文
posted @ 2021-08-20 14:44 做梦当财神 阅读(1568) 评论(0) 推荐(0) 编辑
摘要:Numpy读取文件的3中方法:loadtxt、load、fromfile。 方法 描述 返回数据 loadtxt 读取txt文本、excel文件 数组 load 读取Numpy专用的二进制数据,读取从npy、npz、pickled文件加载数组或pickled对象 数组、元组、字典等 fromfile 阅读全文
posted @ 2021-08-02 22:58 做梦当财神 阅读(8775) 评论(0) 推荐(0) 编辑
摘要:1. 数据源a是数组ndarray时,array仍然会copy出一个副本,占用新的内存,但asarray不会。也就是说改变a的值,b不会。 2. 数据源a是列表时,两者没区别。 阅读全文
posted @ 2019-07-29 16:24 做梦当财神 阅读(4057) 评论(0) 推荐(0) 编辑
摘要:numpy.where (condition[, x, y]) numpy.where()两种用法 1. np.where(condition, x, y) 满足条件(condition),输出x,不满足输出y。 2. np.where(condition) 只有条件 (condition),没有x 阅读全文
posted @ 2019-07-25 20:51 做梦当财神 阅读(1950) 评论(0) 推荐(1) 编辑
摘要:np.repeat()用于将numpy数组重复。 numpy.repeat(a, repeats, axis=None); 参数: axis=0,沿着y轴复制,实际上增加了行数axis=1,沿着x轴复制,实际上增加了列数 1. 一维数组重复3次 # 随机生成[0, 5)之间的数,形状1行4列,将此数 阅读全文
posted @ 2019-07-25 20:36 做梦当财神 阅读(11514) 评论(0) 推荐(0) 编辑
摘要:matrix() 和 array() 的区别,主要从以下方面说起: 1. 矩阵生成方式不同 结果均为: 上述变化就是将 “[]” 换成“()”。不同之处在于 b4 内用引号、空格和分号来产生矩阵,这个方法只可以在 matrix() 函数中使用,即b4 = np.mat('1 2; 3 4')。不可以 阅读全文
posted @ 2019-07-17 15:09 做梦当财神 阅读(3954) 评论(0) 推荐(0) 编辑
摘要:1. 查看数据类型 import numpy as np arr = np.array([1,2,3,4,5]) print(arr) [1 2 3 4 5] # dtype用来查看数据类型 arr.dtype dtype('int32') 2. 转换数据类型 # astype用来转换数据类型 fl 阅读全文
posted @ 2019-07-16 20:26 做梦当财神 阅读(9627) 评论(0) 推荐(0) 编辑
摘要:numpy.unique(ar, return_index=False, return_inverse=False, return_counts=False, axis=None)[source] 一维数组 对一维数组或列表,unique()函数去除其中重复元素,并按元素大小返回一个新的无重复元组或 阅读全文
posted @ 2019-07-11 11:00 做梦当财神 阅读(8389) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示