def reduce(self, a, axis=0, dtype=None, out=None, keepdims=False):  # real signature unknown; restored from __doc__"""reduce(a, axis=0, dtype=None, out=None, keepdims=False)Reduces `a`'s dimension by one, by applying ufunc along one axis.通过沿一个轴应用ufunc将`a`的尺寸减小一倍。Let :math:`a.shape = (N_0, ..., N_i, ..., N_{M-1})`.  Then:math:`ufunc.reduce(a, axis=i)[k_0, ..,k_{i-1}, k_{i+1}, .., k_{M-1}]` =the result of iterating `j` over :math:`range(N_i)`, cumulatively applyingufunc to each :math:`a[k_0, ..,k_{i-1}, j, k_{i+1}, .., k_{M-1}]`.For a one-dimensional array, reduce produces results equivalent to:::令a.shape =(N_0,...,N_i,...,N_ {M-1})`。 然后:ufunc.reduce(a,axis = i)[k_0,..,k_ {i-1},k_ {i + 1},..,k_ {M-1}]`=的结果在:math:`range(N_i)`上迭代`j`,将ufunc累积应用于每个:math:`a [k_0,..,k_ {i-1},j,k_ {i + 1},.., k_ {M-1}]`。 对于一维数组,reduce产生的结果等于:::r = op.identity # op = ufuncfor i in range(len(A)):r = op(r, A[i])return rFor example, add.reduce() is equivalent to sum().例如,add.reduce()等同于sum()。Parameters----------a : array_likeThe array to act on.要作用的数组。axis : None or int or tuple of ints, optionalAxis or axes along which a reduction is performed.The default (`axis` = 0) is perform a reduction over the firstdimension of the input array. `axis` may be negative, inwhich case it counts from the last to the first axis.进行缩小的一个或多个轴。 默认值(“ axis” = 0)是对输入数组的第一维进行缩减。 “轴”可能为负,在这种情况下,它从最后一个轴开始计数。.. versionadded:: 1.7.0If this is `None`, a reduction is performed over all the axes.If this is a tuple of ints, a reduction is performed on multipleaxes, instead of a single axis or all the axes as before.如果为“无”,则对所有轴进行归约。 如果这是一个整数元组,则在多个轴上执行归约,而不是像以前那样在单个轴或所有轴上执行归约。For operations which are either not commutative or not associative,doing a reduction over multiple axes is not well-defined. Theufuncs do not currently raise an exception in this case, but willlikely do so in the future.对于非交换或非关联运算,在多个轴上进行归约的定义不明确。 在这种情况下,ufunc当前不会引发异常,但将来可能会引发异常。dtype : data-type code, optionalThe type used to represent the intermediate results. Defaultsto the data-type of the output array if this is provided, orthe data-type of the input array if no output array is provided.用于表示中间结果的类型。 如果提供此参数,则默认为输出数组的数据类型;如果不提供输出数组,则默认为输入数组的数据类型。out : ndarray, None, or tuple of ndarray and None, optionalA location into which the result is stored. If not provided or `None`,a freshly-allocated array is returned. For consistency with:ref:`ufunc.__call__`, if given as a keyword, this may be wrapped in a1-element tuple.结果存储的位置。 如果未提供或没有,则返回一个新分配的数组。 为了与ufunc .__ call__保持一致,如果作为关键字给出,则可以将其包装在1元素元组中。.. versionchanged:: 1.13.0Tuples are allowed for keyword argument.keepdims : bool, optionalIf this is set to True, the axes which are reduced are leftin the result as dimensions with size one. With this option,the result will broadcast correctly against the original `arr`.如果将其设置为True,则缩小的轴将保留为尺寸1的尺寸。 使用此选项,结果将针对原始`arr`正确广播。.. versionadded:: 1.7.0Returns-------r : ndarrayThe reduced array. If `out` was supplied, `r` is a reference to it.精简数组。 如果提供了`out`,则`r`是对它的引用。Examples-------->>> np.multiply.reduce([2,3,5])30A multi-dimensional array example:>>> X = np.arange(8).reshape((2,2,2))>>> Xarray([[[0, 1],[2, 3]],[[4, 5],[6, 7]]])>>> np.add.reduce(X, 0)    # 次外层相加array([[ 4,  6],[ 8, 10]])>>> np.add.reduce(X) # confirm: default axis value is 0 如果不指定轴,则默认为0(次外层)array([[ 4,  6],[ 8, 10]])>>> np.add.reduce(X, 1)array([[ 2,  4],[10, 12]])>>> np.add.reduce(X, 2)array([[ 1,  5],[ 9, 13]])"""pass

参考文章:numpy高级应用—ufunc

python numpy ufunc.reduce(self, a, axis=0, dtype=None, out=None, keepdims=False)函数.(连续执行原始运算对值聚合)相关推荐

  1. Python Numpy多维数组.sum(axis=0/1/2...) 详解

    Python Numpy多维数组.sum(axis=0/1/2-) 详解 numpy中axis取值的说明 首先对numpy中axis取值进行说明:一维数组时axis=0,二维数组时axis=0,1,维 ...

  2. Python NumPy ufunc 双曲函数(sinh、cosh、arctanh)

    NumPy(Numerical Python的缩写)是一个开源的Python科学计算库.使用NumPy,就可以很自然地使用数组和矩阵.NumPy包含很多实用的数学函数,涵盖线性代数运算.傅里叶变换和随 ...

  3. 【python】详解numpy库与pandas库axis=0,axis= 1轴的用法

    对数据进行操作时,经常需要在横轴方向或者数轴方向对数据进行操作,这时需要设定参数axis的值: axis = 0 代表对横轴操作,也就是第0轴: axis = 1 代表对纵轴操作,也就是第1轴: nu ...

  4. dataframe,python,numpy 问题索引1

    # 找出只有赌场数据的账户 gp=data.groupby(['查询账号','场景标签'],as_index=True) tj=gp.size().reset_index()按查询账号和场景标签分组并 ...

  5. python numpy 中 np.mean(a) 跟 a.mean() 的区别

    今天查看以前写的文章时, 发现有个地方理解不了, 就是 np.mean(a) 跟 a.mean() 的区别是什么, 于是就查阅了相关资料: 官方doc: a.mean() Docstring: a.m ...

  6. python numpy ndarray之basic operations

    之前几节主要学了了ndarray的创建,打印等,但是远远不够,学习numpy本质上是为了使我们算法能够快速实现得到验证,ndarray当然也支持常用的加.减.乘.除基本操作. ndarray的加减乘除 ...

  7. python Numpy模块汇总(字母排序) 备注:内容很多,用control/command(Mac系统)+ F可以在网页内关键词查找,希望你能找到想要的内容

    @[TOC] (目录) Numpy Numpy官网:https://numpy.org/devdocs/index.html Numpy的主要对象是同构多维数组.它是一个元素表(通常是数字),所有类型 ...

  8. python --Numpy详解(科学计算)

    安装 pip install numpy 什么是Numpy:Numeric Python NumPy系统是Python的一种开源的数值计算扩展 一个强大的N维数组对象Array 比较成熟的(广播)函数 ...

  9. Python Numpy知识 - 简约而不简单的 Numpy 小抄表(语法、代码)

    目录 前言 零.安装Numpy 一.Numpy基础 1.常用操作 2.占位符 二.数组 1.数组属性 2.拷贝 /排序 3.数组操作例程 (1)增加或减少元素 (2)组合数组 (3)分割数组 (4)数 ...

最新文章

  1. python 修改xml_如何在python中更新/修改XML文件?
  2. 《流畅的python》第四章 文本和字节序列
  3. wifi协议栈_一文读懂米家部分智能硬件:米家Zigbee及WiFi模块拆解分析
  4. Pytorch教程(十九)torch.cat与torch.stack的区别
  5. 纯js分页代码(简洁实用)
  6. 关于技嘉主板使用win10操作系统关机自动重启的一种解决办法。其他厂家主板也可以尝试一下此方法。
  7. 如何将堆栈跟踪转换为字符串?
  8. 线性方程组的5种描述方式
  9. altium designer 常用元件封装
  10. wincc7.0显示无法访问服务器,WinCC 7.0 SP3 安装时提示网络连接不可用,无法安装...
  11. 地址总线是单向还是双向_双向可控硅和单向可控硅的区别
  12. chrome访问淘宝和京东崩溃,解决方法
  13. 网页中视频内容自动播放
  14. 浅谈学习Scratch的必要性
  15. pycharm32位下载(免费)https://www.jetbrains.com/pycharm/download/other.html
  16. java+MySQL 基于ssm的网上书店图书商城
  17. burpsuite靶场系列之客户端漏洞篇 - 跨站脚本(XSS)专题
  18. 如何提取一个转录本的3'UTR区域的序列
  19. android 动画方式,Android Activity进出动画三种方法
  20. golang学习笔记8 beego参数配置 打包linux命令

热门文章

  1. java tm for chrome_java – 是否可以使用Postman Chrome扩展程序发送hashmap?
  2. linux系统加硬盘容量,Linux系统扩展硬盘空间
  3. python的基本结构_python基础--结构篇
  4. 【学习笔记】33、具有Python特色的循环
  5. 【学习笔记】2、Python - Jupyter Notebook界面基础
  6. 【Python】Flask 框架安装虚拟环境报错—处理中......
  7. 【MM模块】Procurement for Stock Material 库存型物料采购相关
  8. 【MM模块】Cycle Counting 周期盘点
  9. 物料编码原则外部分配还是内部分配
  10. SAP科目的行项目显示未勾选补救步骤