Skip to content

Latest commit

 

History

History
31 lines (30 loc) · 735 Bytes

Python_Numpy_notebook.org

File metadata and controls

31 lines (30 loc) · 735 Bytes

Python Numpy库学习笔记

Copy or View?

  • vew
    • Slice view
    • Dtype view
  • shallow copy
  • deep copy

数组的in place改变

以下是不同的操作过程:

# y = np.arange(8)
y += 1 # 更快
y = y + 1 # 更慢

常用函数

import numpy as np
a = np.arange(3)
b = np.arange(3,6)
c = np.r_[a, b, 1, [3]] # 合并数组
d = np.c_[a, b] # 合并数组
e = np.ones((4, 1)) # 接收元组
d.shape
d.resize(2, 3) # 无返回值,将原数组形变,接收元组
f = d.reshape((2,3)) # 返回变形后的数组,原数组不变,接收元组