1.引用
import numpy as np
核心功能:
- 任意同类项的数组对象
- 数组上的快速数学运算
- 线性代数、傅立叶变换、随机数生成
2. 帮助获取
-
方式1
python3
import numpy
help(numpy) -
方式2
from numpy import doc
help(doc)
he following topics are available:- basics
- broadcasting
- byteswapping
- constants
- creation
- glossary
- indexing
- internals
- misc
- structured_arrays
- subclassing
- ufuncs
You can view them by
help(np.doc.TOPIC)
3. basics
基础数据类型
-
Numpy type C type Description
-
np.bool bool Boolean(True or False) stored as a byte
-
np.byte signed char Platform-defined
-
np.ubyte unsigned char
-
np.short short
-
np.ushort unsigned short
-
np.intc int
-
np.uintc unsigned int
-
np.int_ long
-
np.uint unsigned long
-
np.longlong long long
-
np.ulonglong unsigned long long
-
np.half np.float16
-
np.single float
-
np.double double
-
np.longdouble long double
-
np.csingle float complex
-
np.cdouble double complex
-
np.clongdouble long double complex
-
np.int8 int8_t
-
np.int16 int16_t
-
np.int32 int32_t
-
np.int64 int64_t
-
np.uint8 uint8_t
-
np.uint16 uint16_t
-
np.uint32 uint32_t
-
np.uint64 uint64_t
-
np.float32 float
-
np.float64 double
-
np.complex64 float complex
-
np.complex12 double complex
import numpy as np
x=np.float32(1.0)
x
1.0
y=np.int_([1,2,4])
y
array([1,2,4]
z=np.arange(3, dtype=np.uint8)
z
array([0,1,2], dtype=uint8)
np.array([1,2,3], dtype=‘f’)
array([1., 2., 3.], dtype=float32_
修改类型
z=np.arange(3, dtype=np.uint8)
z.astype(float)
np.int8(z)