Python之numpy库
我遇见的函数
若oo尘
目前在积累,希望能创造出更好的作品
展开
-
【Python之numpy库】15.np.set_printoptions(suppress=True) 将数组科学计数法转化为浮点数
np.set_printoptions(suppress=True) 将数组科学计数法转化为浮点数原创 2021-08-26 17:53:32 · 1636 阅读 · 1 评论 -
【Python之numpy库】14.np.sort() np.argsort() 数组排序
np.sort() np.argsort() 数组排序原创 2021-08-17 11:03:51 · 3726 阅读 · 0 评论 -
【Python之numpy库】12.np.round() 对数组/一堆数保留n位小数
np.round() 对数组/一堆数保留n位小数原创 2021-08-16 21:49:26 · 11804 阅读 · 0 评论 -
【Python之numpy库】13.取数组某一部分时保留维度
取数组某一部分时保留维度原创 2021-08-16 21:49:59 · 3663 阅读 · 1 评论 -
【Python之numpy库】11.np.set_printoptions(threshold=np.inf) 解决输出数组时的省略情况
当数组元素比较多的时候,如果输出该数组,那么会出现省略号解决方法:在程序前写如下代码import numpy as npnp.set_printoptions(threshold=np.inf)原创 2021-08-15 22:00:18 · 3170 阅读 · 5 评论 -
【Python之numpy库】10.np.hstack()和np.c_[]、np.vstack和np.r_[]、np.concatenate 数组的堆叠与平铺
np.hstack()和np.c_[]、np.vstack和np.r_[]、np.concatenate 数组的堆叠与平铺原创 2021-08-14 11:12:56 · 1682 阅读 · 1 评论 -
【Python之numpy库】9.np.random 随机数生成模块常见函数
np.random 随机数生成模块常见函数。1.rand(d0,d1,...,dn)2.randn(d0,d1,...dn)3.randint(low,high=None,size=None,dtype='l')4.uniform(low,high=None,size=None,dtype='l')5.normal(loc=0.0,scale=1.0,size=None)6.shuffle(x)原创 2021-08-11 00:22:02 · 557 阅读 · 0 评论 -
【Python之numpy库】6.axis轴的概念
图+例子讲解axis原创 2021-08-10 13:04:20 · 415 阅读 · 0 评论 -
【Python之numpy库】8.np.sum(x,axis,keepdims) 求和
np.sum原创 2021-08-10 12:17:01 · 913 阅读 · 1 评论 -
【Python之numpy库】7.np.mean 求平均值
操作对象是数组有两个参数,一个是数组,一个是轴代码:import numpy as npa = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [-1, -2, -3, -4], [2, 3, 4, 5]])print(np.mean(a, axis=0)) # 行向量压缩,求平均值print(np.mean(a, axis=1)) # 列向量压缩,求平均值print(原创 2021-08-10 12:09:02 · 2555 阅读 · 0 评论 -
【Python之numpy库】4.np.triu(a,k) 求矩阵上三角
np.triu(a,k) 求矩阵上三角原创 2021-08-07 23:36:09 · 1457 阅读 · 0 评论 -
【Python之numpy库】5.np.piecewise 操作方程
np.piecewise转载 2021-08-08 00:18:02 · 1400 阅读 · 0 评论 -
【Python之numpy库】2.np.diff() 矩阵后一个数减前一个数
np.diff()函数的使用原创 2021-08-05 09:51:18 · 1905 阅读 · 0 评论 -
【Python之numpy库】1.flatten() 展开数组
作用:把numpy的数组按规定方向展成一维的数组默认的方向是行方向,若‘f’则是列方向,‘a’是行方向代码:import numpy as npa=np.array([[1,2,3], [4,5,6], [7,8,9]])b=a.flatten()c=a.flatten('f')d=a.flatten('a')print(b)print(c)print(d)结果:[1 2 3 4 5 6 7 8 9][1 4 7 2 5原创 2021-08-04 15:44:41 · 2467 阅读 · 1 评论 -
【Python之numpy库】3.np.linalg.pinv和np.linalg.inv 求逆矩阵与伪逆矩阵
np.linalg.pinv和np.linalg.inv 求逆矩阵与伪逆矩阵原创 2021-08-05 10:26:58 · 8279 阅读 · 0 评论