python3 numpy学习

1.引用

import numpy as np
核心功能:

  1. 任意同类项的数组对象
  2. 数组上的快速数学运算
  3. 线性代数、傅立叶变换、随机数生成

  4. 帮助获取

  5. 方式1
    python3
    import numpy
    help(numpy)

  6. 方式2
    from numpy import doc
    help(doc)
    he following topics are available:
  7. basics
  8. broadcasting
  9. byteswapping
  10. constants
  11. creation
  12. glossary
  13. indexing
  14. internals
  15. misc
  16. structured_arrays
  17. subclassing
  18. ufuncs You can view them by
    help(np.doc.TOPIC)

  19. 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)

Original: https://blog.csdn.net/yaffils79/article/details/122211649
Author: yaffils79
Title: python3 numpy学习

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/763146/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球