当前位置:网站首页>Numpy common function table sorting of data processing
Numpy common function table sorting of data processing
2022-04-23 05:56:00 【ShuangTwo】
function | Concrete realization : In the table a, b Represents an array |
---|---|
Import numpy library | import numpy as np |
Use array Create array | np.array(([1,2,3],[4,5,6])) |
Creates an array of the specified data type | np.array([[1,2,3],[4,5,6]], dtype=np.int32) |
Create an array of default data types | np.arange(5) |
from 1 To 2 Generate 5 A floating point number | np.linspace(1,2,5) |
Create whole 0 Array | np.zeros((2,3)) |
Create whole 0 Array | np.ones((2,3)) |
The main diagonal element is 1 The other elements are 0 | arr = np.eye(3) |
Generate [0,1) Between random floating-point numbers | np.random.random((2,3)) |
Generate [0,10) Random integer between | np.random.randint(0,10,(3,2)) |
Data type of array element | a.dtype |
The number of bytes of memory occupied by array elements | a.dtype.itemsize |
The number of bytes of memory occupied by array elements | a.itemsize |
Dimension of array | a.shape |
Number of array elements | a.size |
Array row variable column , Be similar to transpose() | a.T |
Row to column ( It's like matrix transposition ) | a.transpose() |
View array dimensions | a.shape |
return 3 That's ok 2 Array of columns | a.reshape(3,2) |
Returns a one-dimensional array | a.ravel() |
The last element | a[-1] |
Back to page 2 To the first 5 Elements | a[2:5] |
Back to page 0 To the first 7 Elements , In steps of 3 | a[:7:3] |
Returns an array in reverse order | a[::-1] |
Horizontal merger | np.hstack((a,b)) |
Merge vertically | np.vstack((a,b)) |
Deep merge | np.dstack((a,b)) |
Horizontal split , return list | np.hsplit(a, 3) |
Split Vertically , return list | np.vsplit(a, 3) |
Deep split , return list | np.dsplit(a, 3) |
Arrays and constants can do four operations | a+2 |
Arrays and arrays can do four operations | a/b |
Determine whether the array is equal | (a == b).all() |
Sum of all elements | a.sum() |
The product of all elements | a.prod() |
The arithmetic mean of all elements | a.mean() |
The maximum value of all elements | a.max() |
The minimum of all elements | a.min() |
Less than 3 The element of is replaced by 3, Greater than 4 The element of is replaced by 4 | a.clip(3,4) |
Return is greater than the 2 Array of elements of | a.compress(a>2) |
return python Of list | a.tolist() |
Calculate variance ( The mean of the square of the difference between the element and the mean ) | a.var() |
Calculate the standard deviation ( The arithmetic square root of variance ) | a.std() |
Returns the difference between the maximum and minimum values of an array | a.ptp() |
Returns the index of the minimum value in a flat array | a.argmin() |
Returns the index of the maximum value in a flat array | a.argmax() |
Return all values as 2 The index of the element | np.where(a == 2) |
Returns the difference between adjacent elements | np.diff(a) |
Returns a logarithmic array | np.log(a) |
Returns an array of exponents | np.exp(a) |
Return the square root array | np.sqrt(a |
Array sorting | np.msort(a |
Returns the maximum value array of corresponding position elements in multiple arrays | np.maximum(a, b) |
Returns the minimum value array of corresponding position elements in multiple arrays | np.minimum(a, b) |
Real mathematical division of integers | np.true_divide(a, b) |
版权声明
本文为[ShuangTwo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230541368408.html
边栏推荐
- 事实最终变量与最终变量
- Pyemd installation and simple use
- PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比
- Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
- 多线程与高并发(3)——synchronized原理
- Meta annotation (annotation of annotation)
- PyQy5学习(二):QMainWindow+QWidget+QLabel
- JVM series (3) -- memory allocation and recycling strategy
- MySql基础狂神说
- 字符串(String)笔记
猜你喜欢
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
基于thymeleaf实现数据库图片展示到浏览器表格
去噪论文阅读——[CVPR2022]Blind2Unblind: Self-Supervised Image Denoising with Visible Blind Spots
Pyqy5 learning (III): qlineedit + qtextedit
你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问
Gaussian processes of sklearn
opensips(1)——安装opensips详细流程
Pyemd installation and simple use
jdbc入门\获取数据库连接\使用PreparedStatement
实操—Nacos安装与配置
随机推荐
Pyqy5 learning (2): qmainwindow + QWidget + qlabel
jdbc入门\获取数据库连接\使用PreparedStatement
Split and merge multiple one-dimensional arrays into two-dimensional arrays
mysql sql优化之Explain
Anaconda安装PyQt5 和 pyqt5-tools后没有出现designer.exe的问题解决
2.devops-sonar安装
编写一个自己的 RedisTemplate
JDBC操作事务
Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
MySQL realizes master-slave replication / master-slave synchronization
mysql实现主从复制/主从同步
字符串(String)笔记
软件架构设计——软件架构风格
Excel obtains the difference data of two columns of data
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images
MySQL的锁机制
EditorConfig
基于thymeleaf实现数据库图片展示到浏览器表格
多个一维数组拆分合并为二维数组