当前位置:网站首页>numpy.frombuffer()
numpy.frombuffer()
2022-06-26 05:48:00 【Wanderer001】
参考numpy.frombuffer() - 云+社区 - 腾讯云
numpy.frombuffer
numpy.frombuffer(buffer, dtype=float, count=-1, offset=0)
Interpret a buffer as a 1-dimensional array.
| Parameters: | buffer : buffer_like An object that exposes the buffer interface. dtype : data-type, optional Data-type of the returned array; default: float. count : int, optional Number of items to read. offset : int, optional Start reading the buffer from this offset (in bytes); default: 0. |
|---|
Notes
If the buffer has data that is not in machine byte-order, this should be specified as part of the data-type, e.g.:
>>> dt = np.dtype(int)
>>> dt = dt.newbyteorder(‘>‘)
>>> np.frombuffer(buf, dtype=dt)The data of the resulting array will not be byteswapped, but will be interpreted correctly.
Examples
>>> s = ‘hello world‘
>>> np.frombuffer(s, dtype=‘S1‘, count=5, offset=6)
array([‘w‘, ‘o‘, ‘r‘, ‘l‘, ‘d‘],
dtype=‘|S1‘)>>> np.frombuffer(b‘\x01\x02‘, dtype=np.uint8)
array([1, 2], dtype=uint8)
>>> np.frombuffer(b‘\x01\x02\x03\x04\x05‘, dtype=np.uint8, count=3)
array([1, 2, 3], dtype=uint8)NumPy的ndarray数组对象不能像list一样动态地改变其大小,在做数据采集时很不方便。本文介绍如何通过np.frombuffer()实现动态数组。
边栏推荐
- 操作符的优先级、结合性、是否控制求值顺序【详解】
- The model defined (modified) in pytoch loads some required pre training model parameters and freezes them
- Operator priority, associativity, and whether to control the evaluation order [detailed explanation]
- Overloading and overriding
- C XX management system
- A new explanation of tcp/ip five layer protocol model
- Life is so fragile
- DOM document
- Some doubts about ARP deception experiment
- Gram matrix
猜你喜欢

类和对象的学习

How to use the tablet as the second extended screen of the PC

Adapter mode

电商借助小程序技术发力寻找增长突破口

Could not get unknown property ‘*‘ for SigningConfig container of type org. gradle. api. internal

10 set

DOM文档

Could not get unknown property ‘*‘ for SigningConfig container of type org.gradle.api.internal

REUSE_ ALV_ GRID_ Display event implementation (data_changed)

Sofa weekly | open source person - Yu Yu, QA this week, contributor this week
随机推荐
About XXX management system (version C)
Easy to understand from the IDE, and then talk about the applet IDE
12 multithreading
String类学习
Daily production training report (16)
【 langage c】 stockage des données d'analyse approfondie en mémoire
Could not get unknown property ‘*‘ for SigningConfig container of type org.gradle.api.internal
5分钟包你学会正则表达式
423-二叉树(110. 平衡二叉树、257. 二叉树的所有路径、100. 相同的树、404. 左叶子之和)
Consul服务注册与发现
Source code of findcontrol
售前分析
421- binary tree (226. reversed binary tree, 101. symmetric binary tree, 104. maximum depth of binary tree, 222. number of nodes of complete binary tree)
Internship May 29, 2019
Day4 branch and loop
MySQL database-01 database overview
BOM document
DOM document
421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)
Leetcode513. Find the value in the lower left corner of the tree