We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
numpy 高级应用
ndarray 内部组成
Numpy 数据类型体系
dtype 都有一个超类(比如np.integer, np.floating), 他们可以跟np.issubdtype 函数结合使用
ints = np.ones(10, dtype=np.uint16) floats = np.ones(10, dtype=np.float32) np.issubdtype(ints.dtype, np.integer) # True np.issubdtype(floats.dtype, np.floating)
dtype.mro 可以查看其所有的父类
数组重塑
reshape
arr = np.arange(8) arr # array([0, 1, 2, 3, 4, 5, 6, 7]) arr.reshape((4, 2)) # array([[0, 1], # [2, 3], # [4, 5], # [6, 7]])
扁平化
ravel flatten 产生副本
arr.ravel() # array([0, 1, 2, 3, 4, 5, 6, 7] arr.flatten # array([0, 1, 2, 3, 4, 5, 6, 7]
C 和 Fortran 顺序 Fortran 矩阵列优先 C 行优先
数组的合并和拆分
合并
arr1 = np.array([[1, 2, 3], [4, 5, 6]]) arr2 = np.array([[7, 8, 9], [10, 11, 12]]) np.concatenate([arr1, arr2], axis=0) # OR np.vstack((arr1, arr2)) # array([[ 1, 2, 3], # [ 4, 5, 6], # [ 7, 8, 9], # [10, 11, 12]]) np.concatenate([arr1, arr2], axis=1) # OR np.hstack((arr1, arr2)) # array([[ 1, 2, 3, 7, 8, 9], # [ 4, 5, 6, 10, 11, 12]])
拆分 np.split
广播
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Data Analysis with Python——07
numpy 高级应用
ndarray 内部组成
Numpy 数据类型体系
dtype 都有一个超类(比如np.integer, np.floating), 他们可以跟np.issubdtype 函数结合使用
dtype.mro 可以查看其所有的父类
数组重塑
reshape
扁平化
ravel
flatten 产生副本
C 和 Fortran 顺序
Fortran 矩阵列优先
C 行优先
数组的合并和拆分
合并
拆分
np.split
广播
The text was updated successfully, but these errors were encountered: