python arg_python argmin_python中argmin函数_Python numpy.argmin(
numpy.argmin(array,axis = None,out = None):返回特定轴上数组min元素的索引。
参数:
array:Input array to work on
axis :[int, optional]Along a specified axis like 0 or 1
out :[array optional]Provides a feature to insert output to the out
array and it should be of appropriate shape and dtype
返回:
Array of indices into the array with same shape as array.shape
with the dimension along axis removed.
代码1:
# Python Program illustrating
# working of argmin()
import numpy as geek
# Working on 1D array
array = geek.arange(8)
print("INPUT ARRAY:\n", array)
# returning Indices of the min element
# as per the indices
print("\nIndices of min element:", geek.argmin(array, axis=0))
输出:
INPUT ARRAY:
[0 1 2 3 4 5 6 7]
Indices of min element: 0
代码2:
# Python Program illustarting
# working of argmin()
import numpy as geek
# Working on 2D array
array = geek.random.randint(16, size=(4, 4))
print("INPUT ARRAY:\n", array)
# returning Indices of the min element
# as per the indices
'''
[[ 8 13 5 0]
[ 0 2 5 3]
[10 7 15 15]
[ 3 11 4 12]]
^ ^ ^ ^
0 2 4 0 - element
1 1 3 0 - indices
'''
print("\nIndices of min element:", geek.argmin(array, axis = 0))
输出:
INPUT ARRAY:
[[ 8 13 5 0]
[ 0 2 5 3]
[10 7 15 15]
[ 3 11 4 12]]
Indices of min element: [1 1 3 0]
代码3:
# Python Program illustarting
# working of argmin()
import numpy as geek
# Working on 2D array
array = geek.arange(10).reshape(2, 5)
print("array:\n", array)
array[0][0] = 10
array[1][1] = 1
array[0][1] = 1
print("\narray:\n", array)
# Returns min element
print("\narray:", geek.argmin(array))
# First occurrence of an min element is given
print("\nmin ELEMENT INDICES:", geek.argmin(array, axis = 0))
输出:
array:
[[0 1 2 3 4]
[5 6 7 8 9]]
array:
[[10 1 2 3 4]
[ 5 1 7 8 9]]
array: 1
min ELEMENT INDICES: [1 0 0 0 0]
python arg_python argmin_python中argmin函数_Python numpy.argmin(相关推荐
- python中argmin函数_Python numpy.argmin()用法及代码示例
numpy.argmin(array,axis = None,out = None):返回特定轴上数组min元素的索引. 参数: array:Input array to work on axis : ...
- python中argmin函数_python中argmin函数_Python numpy.argmin()用法及代码示例
numpy.argmin(array,axis = None,out = None):返回特定轴上数组min元素的索引. 参数: array:Input array to work on axis : ...
- python 中arange函数_Python numpy.arange函数方法的使用
numpy.arange numpy.arange([start, ]stop, [step, ]dtype=None) 返回给定间隔内的均匀间隔的值. 在半开间隔[start,stop)(换句话说, ...
- python中grid函数_Python / NumPy中meshgrid的目的是什么?
实际上文档中已经提到了np.mgrid的目的: np.mgrid 从坐标向量返回坐标矩阵. 在给定一维坐标数组x1,x2,...,xn的情况下,为N-D网格上的N-D标量/矢量场的矢量化评估制作N-D ...
- python中squeeze函数_Python numpy.squeeze()用法及代码示例
当我们要从数组形状中删除一维条目时,将使用numpy.squeeze()函数. 用法: numpy.squeeze(arr, axis=None ) 参数: arr :[数组]输入数组. axis : ...
- python中isin函数_Python numpy.isin函数方法的使用
numpy.isin numpy.isin(element, test_elements, assume_unique=False, invert=False) [source] 计算test ...
- python中mat函数_Python Numpy中的Matlab cell2mat函数?
从某种意义上说,Python的"cells"比MATLAB-list长得多.python列表是1d单元格(或者更确切地说,大小为1维的单元格)的直接替代品.二维单元格可以表示为嵌套 ...
- python中reshape函数_Python numpy.reshape函数方法的使用
numpy.reshape numpy.reshape(a, newshape, order='C') [source] 在不更改数据的情况下为数组赋予新的shape.参数 :a :array_ ...
- python中full函数_Python numpy.full_like函数方法的使用
numpy.full_like numpy.full_like(a, fill_value, dtype=None, order='K', subok=True)[source] 返回与给定数组具有相 ...
最新文章
- MATLAB_no.3:关于车牌的.
- 线上会议丨中国中文信息学会2020学术年会将于12月27日举行
- 搭建SSH框架之一(资料准备)
- 创立一家互联网公司,需要几步?
- python函数拟合不规则曲线_python曲线拟合
- web自动化如何在不同浏览器运行_自动化决策环节的“心脏”将如何与众不同?...
- IronPython 与C#交互
- access vba 用recordset读取表中数据的简单方法
- java 字符串原样输出_Java 中如何原样输出转义符号
- 心情的旅行- 让自己慢下来(46)
- Confluence 6 创建一个用户宏
- 蓝桥杯 基础练习 数列特征
- Java读书笔记(8)-单例模式
- 网易丁磊:中国的安卓分成全世界最贵 比苹果贵20%左右
- 嵌入式软件设计第11次实验报告
- 阶段1 语言基础+高级_1-3-Java语言高级_08-JDK8新特性_第3节 两种获取Stream流的方式_6_Stream流中的常用方法_count...
- 怎么从零编写一个 v3 版本的 chrome 浏览器插件实现 CSDN 博客网站的暗黑和明亮主题切换?
- 1047: 对数表 Python
- 必应词典的使用和分析
- matlab极坐标系作图,matlab极坐标作图