4.1 The NumPy ndarray: A Multidimensional Array Object
Creating ndarrays

Data Types for ndarrays

np.astype 轉(zhuǎn)換類型
Fancy Indexing
Transposing Arrays and Swapping Axes
ndarray.T
numpy.transpose
https://blog.csdn.net/Hearthougan/article/details/72626643
剛開始看這些數(shù)據(jù),根本沒有頭緒,這就要理解transpose()中的參數(shù)的意義,因?yàn)閿?shù)組a的shape為(2,3,5),是一個(gè)三維數(shù)組,那么這個(gè)元組對(duì)應(yīng)的索引為:(0,1,2),也就是a.shape的下標(biāo):(2[0], 3[1], 5[2]), []中對(duì)應(yīng)的是shape元組的索引。那么,現(xiàn)在,通過b = a.transpose(1, 0, 2),那么b.shape就變成(3, 2, 5),這就是說transpose就是改變高維數(shù)組的形狀,形狀改變了,那么里面的元素自然也要重新排列,比如:元素11在a中的位置是a[0][2][1],經(jīng)過b = a.transpose(1, 0, 2)之后,11在b中的位置就變成b[2][0][1]。再比如元素28,在a中的位置a[1][2][3],在b中為:a[2][1][3].
numpy.swapaxes
example: arr.swapaxes(2,1) #就是將第三個(gè)維度和第二個(gè)維度交換
4.2 Universal Functions: Fast Element-Wise Array Functions


4.3 Array-Oriented Programming with Arrays
Expressing Conditional Logic as Array Operations
np.where(cond, xarr, yarr)等于x if c else y
Mathematical and Statistical Methods

Methods for Boolean Arrays
any tests whether one or more values in an array is True , while all checks if every value is True
Sorting
ndarray.sort(axis=-1, kind='quicksort', order=None)
使用方法:a.sort
參數(shù)說明:
axis:排序沿著數(shù)組的方向,0表示按行,1表示按列
kind:排序的算法,提供了快排、混排、堆排
order:不是指的順序,以后用的時(shí)候再去分析這個(gè)
作用效果:對(duì)數(shù)組a排序,排序后直接改變了a
作者:吃土的司機(jī)
鏈接:http://www.itdecent.cn/p/b4d46c612ae4
來源:簡(jiǎn)書
著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請(qǐng)注明出處。
Unique and Other Set Logic

4.4 File Input and Output with Arrays
np.save
np.savez
np.load
np.savez_compressed
4.5 Linear Algebra

4.6 Pseudorandom Number Generation
