.Ipynb native code is converted to the format of the blog a lot of trouble, showing part of the code here to find out more you can see my git-hub: https: //github.com/Yangami/Python-for-Statisticians/tree/master/ Numpy
#-*-author Yangami-*-
import numpy as np
import pandas as pd
shape
# Create an array A = np.array ([l, 2,3 ]) B = np.arange (. 9 ) A, B, type (A) C = np.array ([[[l, 2,3], [ 2,4,6]], [[l, 2,3], [2,4,6 ]]]) C np.shape (C) np.shape (A) np.array ([[[ 1,2 , 3], [4,5,6]], [[1,2,3], [4,5,6 ]]]) # array to a list c.tolist ()
reshape
a=np.array([[1,2,3,4,5,6]]) a.reshape(6,1) a.reshape(2,3) np.array([60, 31, 54, 78,89,34,65,78,56,77,88,44 ]).reshape(3,4) a.reshape(1,-1)
Basic operations
A A. 1 + A 2 * np.log (A)
A # conditions are selected to return bool value A> 2 # bool value indexed A [A> 2 ] # # split merge A a.reshape = (2,3 ) A # take a line A [. 1 ] # taking a column A [1,1 :] A [. 1] [2 ] # of elements having A [1,2], A [. 1] [2 ] # split array a1 = a [:,:. 1 ] A2 = A [:,. 1 :] Print (A1, ' \ n- ' , A2) # merge array A1 + A2 hstack ((A1, A2)) vStack ((A [0], A [. 1 ]))