#single-line comment" " Multi-line Comment Multiline Comment multi-line Comment" "#A.ndim The number of dimensions of the output array;#a.shape output Array form (several rows, several columns)#copy () copies an array#multiply each element in the a*2 array by 2#[1,2]*2 Array will become 4#a**2 a squared#[1,2]**2 unsuported operand type#array Access. Build outliers. Handles a value that does not exist. #clip () Trim off part of an interval boundary#mean () mean value#handling values that do not existImportNumPy as NPA= Np.array ([0,1,2,3,4,5]) b= A.reshape ((3,2))#Transport a array to B. Change B same to a.C= A.reshape ((3,2)). Copy ()#Change c No change a.they is depended.A[a>4] = 2#Trimming Outlier ValuesD= A.clip (0,2)#maximum of 2 in De= Np.array ([1,2,NP. nan,3,4])## Np.isnan (e) to determine if an array has an unreasonable valueF = E[~np.isnan (e)]## E[~np.isnan (e)] output a reasonable numberm= Np.mean (E[~np.isnan (e)])##均值. ##应该时常考虑如何将数组元素的循环处理冲Python中移到高度优化的NumPy: scipy extension function (validation negation)#example the sum of all squares of 1~1000Importtimeitnormal_py_sec= Timeit.timeit ('sum (x*x for x in Xrange ())', number= 1000) Naive_np_sec= Timeit.timeit ('sum (na*na)', Setup="Import NumPy as Np;na=np.arange (+)", number= 1000) Good_np_sec= Timeit.timeit ('Na.dot (NA)', Setup="import NumPy as NP; Na=np.arange (+)", number= 1000)Print("Normal Python:%f sec"%normal_py_sec)Print("Naive Python:%f sec"%naive_np_sec)Print("Good NumPy:%f sec"%good_np_sec)" "Normal python:0.081011 secnaive python:0.384903 secgood numpy:0.013812 sec Experience, there is no much difference. With" "
"Machine Learning in Python" (NumPy)