numpy Flashcards
create an array [a,…, n] with step size x
numpy.arange(a, n+1, x)
add arr2 to the end of arr1
numpy.append(arr1, arr2)
calculate std for arr
np.std(arr, ddof = 1)
calculate the covariance of two arrs
np.cov(x,y)[0,1]
calculate the correlation coefficient of two arrs
np.corrcoef(x, y)[0,1]
the product of all elements in an array x
np.prod(x)
create a new array and its elements are element wise sums from arr1 and arr2.
x = arr1 + arr2
get an array of k zeros in it
numpy.zeros(k)
mean of arr
arr.mean() or numpy.mean(arr)
median of arr
np.median(arr)
variance of an array
np.var(arr, ddof =1)
the covariance of the two arrays
np.cov(arr1, arr2)[0,1]
the covariance matrix of the two arrays
np.cov(arr1, arr2)
correlation coefficient matrix of two arrays
np.corrcoef(arr1,arr2)
log transform a column
df[‘log_value’] = np.log(df[‘value’])