当前位置:网站首页>数据处理之Numpy常用函数表格整理
数据处理之Numpy常用函数表格整理
2022-04-23 05:42:00 【ShuangTwo】
| 功能 | 具体实现:表中a, b表示数组 |
|---|---|
| 导入numpy库 | import numpy as np |
| 使用array创建数组 | np.array(([1,2,3],[4,5,6])) |
| 创建指定数据类型的数组 | np.array([[1,2,3],[4,5,6]], dtype=np.int32) |
| 创建默认数据类型的数组 | np.arange(5) |
| 从1到2生成5个浮点数 | np.linspace(1,2,5) |
| 创建全0数组 | np.zeros((2,3)) |
| 创建全0数组 | np.ones((2,3)) |
| 主对角线元素为1其他元素为0 | arr = np.eye(3) |
| 生成[0,1)之间的随机浮点数 | np.random.random((2,3)) |
| 生成[0,10)之间的随机整数 | np.random.randint(0,10,(3,2)) |
| 数组元素的数据类型 | a.dtype |
| 数组元素占据的内存字节数 | a.dtype.itemsize |
| 数组元素占据的内存字节数 | a.itemsize |
| 数组的维度 | a.shape |
| 数组元素个数 | a.size |
| 数组行变列,类似于transpose() | a.T |
| 行变列(类似于矩阵转置) | a.transpose() |
| 查看数组维度 | a.shape |
| 返回3行2列的数组 | a.reshape(3,2) |
| 返回一维数组 | a.ravel() |
| 最后一个元素 | a[-1] |
| 返回第2到第5个元素 | a[2:5] |
| 返回第0到第7个元素,步长为3 | a[:7:3] |
| 返回逆序的数组 | a[::-1] |
| 水平合并 | np.hstack((a,b)) |
| 垂直合并 | np.vstack((a,b)) |
| 深度合并 | np.dstack((a,b)) |
| 水平拆分,返回list | np.hsplit(a, 3) |
| 垂直拆分,返回list | np.vsplit(a, 3) |
| 深度拆分,返回list | np.dsplit(a, 3) |
| 数组和常数可以进行四则运算 | a+2 |
| 数组和数组可以进行四则运算 | a/b |
| 判断数组是否相等 | (a == b).all() |
| 所有元素的和 | a.sum() |
| 所有元素的乘积 | a.prod() |
| 所有元素的算数平均值 | a.mean() |
| 所有元素的最大值 | a.max() |
| 所有元素的最小值 | a.min() |
| 小于3的元素替换为3,大于4的元素替换为4 | a.clip(3,4) |
| 返回大于2的元素组成的数组 | a.compress(a>2) |
| 返回python的list | a.tolist() |
| 计算方差(元素与均值之差的平方的均值) | a.var() |
| 计算标准差(方差的算术平方根) | a.std() |
| 返回数组的最大值和最小值之差 | a.ptp() |
| 返回最小值在扁平数组中的索引 | a.argmin() |
| 返回最大值在扁平数组中的索引 | a.argmax() |
| 返回所有值为2的元素的索引 | np.where(a == 2) |
| 返回相邻元素的差 | np.diff(a) |
| 返回对数数组 | np.log(a) |
| 返回指数数组 | np.exp(a) |
| 返回开方数组 | np.sqrt(a |
| 数组排序 | np.msort(a |
| 返回多个数组中对应位置元素的最大值数组 | np.maximum(a, b) |
| 返回多个数组中对应位置元素的最小值数组 | np.minimum(a, b) |
| 对整数实现真正的数学除法运算 | np.true_divide(a, b) |
版权声明
本文为[ShuangTwo]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43356538/article/details/114685487
边栏推荐
- MDN文档里面入参写法中括号‘[]‘的作用
- Xiuxian real world and game world
- MySQL triggers, stored procedures, stored functions
- Golang implements Ping connectivity detection case through exec module
- Pytorch deep learning practice_ 11 convolutional neural network
- 框架解析1.系统架构简介
- Data mining -- understanding data
- JDBC工具类封装
- MySQL lock mechanism
- Idea plug-in --- playing songs in the background
猜你喜欢

2-軟件設計原則

Transposed convolution

Hongji cyclone RPA provides technical support for Guojin securities and realizes process automation in more than 200 business scenarios

橙单微服务之批量导入

第36期《AtCoder Beginner Contest 248 打比赛总结》

AcWing 836. Merge set (merge set)

deep learning object detection

Excel sets row and column colors according to cell contents

Issue 36 summary of atcoder beginer contest 248

mysql sql优化之Explain
随机推荐
转置卷积(Transposed Convolution)
Deep learning object detection
Markdown syntax support test
多线程与高并发(1)——线程的基本知识(实现,常用方法,状态)
Frequently asked interview questions - 1 (non technical)
Introduction to data security -- detailed explanation of database audit system
freemark中插入图片
Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
Solid contract DoS attack
C language - Spoof shutdown applet
Flutter 新一代图形渲染器 Impeller
Total score of [Huawei machine test] (how to deal with the wrong answer? Go back once to represent one wrong answer)
solidity合约DOS攻击
Map对象 map.get(key)
Add days to date
Range of numbers (dichotomous classic template topic)
Hongji | how does HR carry out self change and organizational change in the digital era?
Flutter 新一代圖形渲染器 Impeller
类的加载与ClassLoader的理解
The list attribute in the entity is empty or null, and is set to an empty array