当前位置:网站首页>numpy 多维数组ndarray的详解
numpy 多维数组ndarray的详解
2022-07-30 05:49:00 【夕阳染色的坡道】
Numpy 的 Ndarray对象
Numpy 一个重要的特点是其N维数组对象ndarray,它是一系列同类数据集合,以0下标为开始进行集合中元素的索引。类似于C++的vector的多维数组。
下面是Ndarray的特点(不同于python 的 list)
ndarray对象是用于存放同类型元素的多维数组。(如:都是float,str,或者int 等等,但是它们必须是同种一个类型。)
ndarray中的每个元素在内存中都有相同的存储大小的区域
基于上述的特点,ndarray内部由以下内容组成:
1)一个指向数据(内存或者内存映射文件中的一块数据)的指针。
2)数据类型或dtype,描述在数组中的固定大小值的格子。
3)一个表示数组形状(shape)的元组,表示各个维度大小的元组。
4)一个跨度(stride),其中的整数指的是为了前进到当前维度下一个元素需要“跨过”的字节数。
创建一个ndarray数组,只需要调用numpy 的array函数即可:
numpy.array(object, dtype=None,copy=True,order=None,subok=false,ndmin=0)
| 名称 | 描述 |
|---|---|
| object | 数组或者嵌套的数列 |
| dtype | 数组元素的数据结构,可选 |
| copy | 对象是否需要复制,可选 |
| order | 创建数组的样式,C 为行方向,F为列方向,A为任意方向 |
| subbok | 默认返回一个与基类一致的数组 |
| ndmin | 指定生成数组的最小维度 |
上述为python的numpy模块中的多维数组的用法,需要通过列子来测试一下它的用法。如下:
1:创建一维数组
2:创建二维数组
3:测试ndmin参数
4:测试参数dtype参数
总结:narray多维数组是numpy模块非常重要的部分。操作narray数组继承了python的操作。它和python的list,str,float等等相互转化。
边栏推荐
- How to create a shortcut without the "shortcut" suffix?
- Test development engineer growth diary 016 - those things about the test
- Test Development Engineer Growth Diary 015 - Top 20 Test Interview Questions
- 02-Cycript的使用
- Network Protocol 03 - Routing and NAT
- MongoDB - Introduction, Data Types, Basic Statements
- Vineyard: An open source distributed in-memory data management framework
- 黑盒测试的概念及测试方法
- Application of graph computing in network security analysis
- 多线程基础(概念,创建,中断)
猜你喜欢

02-Use of Cycript

空间顶点到直线的距离计算及其源码

Linx常见目录&文件管理命令&VI编辑器使用 介绍

prometheus监控mysql

Test Development Engineer Growth Diary 018 - Record of Required Questions for Test Interview (Continuous Update)

MySql connecting to the server remotely

matlab机器学习_01

Graph Computing 101: Types, Languages, and Systems of Graph Computing

Advanced multi-threading (lock strategy, spin+CAS, Synchronized, JUC, semaphore)

如何理解普吕克坐标(几何理解)
随机推荐
新人误删数据,组长巧用MySQL主从复制延迟挽回损失
As a test leader, examine several aspects of job candidates
MongoDB-介绍,数据类型,基本语句
CTO说不建议我使用SELECT * ,这是为什么?
牛客:删除公共字符
SE_01
Advanced multi-threading (CountDownLatch, deadlock, thread-safe collection class)
Test Development Engineer Growth Diary 010 - CI/CD/CT in Jenkins (Continuous Integration Build/Continuous Delivery/Continuous Testing)
GAIA-IR: Parallelized Graph Query Engine on GraphScope
Local Implicit Grid Representations for 3D Scenes详解
使用Apifox测试套件自动化测试接口
Data types of Redis6
How to import matlab data into modelsim simulation
Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment
作为测试leader,考察求职者的几个方面
PXE高效批量网络装机
npm安装nodejs环境配置
openstack删除计算节点
空间直线到平面上的交点的计算证明及其源码
Dachang's annual salary of 50w+ recruits test engineers with test platform development capabilities