1、查看np数组的属性与方法
~~~
# 导入np库
import numpy as np
#定义一个python普通列表
a = [1,2,3,4,5,6]
# python普通列表转化为成np数组
np_a = np.array(a)
# np数组的属性与方法
print(dir(np_a))
~~~
结果:
~~~
['T', '__abs__', '__add__', '__and__', '__array__', '__array_finalize__', '__array_interface__', '__array_prepare__',
'__array_priority__', '__array_struct__', '__array_wrap__', '__bool__', '__class__', '__complex__',
'__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dir__', '__divmod__',
'__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__',
'__imul__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__ior__', '__ipow__',
'__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__lshift__', '__lt__', '__matmul__',
'__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__',
'__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmatmul__',
'__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__',
'__rxor__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__',
'__truediv__', '__xor__', 'all', 'any', 'argmax', 'argmin', 'argpartition', 'argsort', 'astype', 'base',
'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod',
'cumsum', 'data', 'diagonal', 'dot', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield',
'imag', 'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder',
'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real', 'repeat', 'reshape', 'resize', 'round', 'searchsorted',
'setfield', 'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 'swapaxes', 'take', 'tobytes',
'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'var', 'view']
~~~
2、NumPy的数组中比较重要ndarray对象属性
查看一维数组
~~~
# 数组中数据类型
print(np_a.dtype)
# 数组的维数,秩
print(np_a.ndim)
# 数组的维度
print(np_a.shape)
# 数组元素的总个数
print(np_a.size)
~~~
结果
~~~
int32
1
(6,)
6
~~~
看看二维数组
~~~
import numpy as np
a = [[1.1,2.3,3.6,4.9],[5.2,6.3,7.5,8.9]]
np_a = np.array(a)
print(type(np_a))
# 数组中数据类型
print(np_a.dtype)
# 数组的维数,秩
print(np_a.ndim)
# 数组的维度
print(np_a.shape)
# 数组元素的总个数
print(np_a.size)
~~~
结果
~~~
<class 'numpy.ndarray'>
float64
2
(2, 4)
8
~~~
- Python 环境
- Python 安装
- IDE
- 包安装
- Anaconda
- WinPython
- eclipse
- eclipse安装
- pydev安装
- 常用英汉
- emmet
- base
- list
- 包 模块 导入
- 查看版本
- dir()
- type 数据类型
- if
- while for
- 迭代器和生成器
- + 和 +=
- numpy
- 体质指数
- 版本
- np数组属性
- 子集
- 数据创建
- 基本操作
- plot
- 中文显示问题
- 随机数
- ::的用法
- asammdf
- 获取所有信号
- 导出csv
- pygraph
- pandas
- 数据结构
- pandans十分钟入门
- io
- 爬小说
- struct
- mdf
- ascii
- bytes & bytearray
- 任务
- aardio读取二进制文件原样输出
- 读取数字
- mdf 数据转换
- charles

