import numpy as np
arr = np. array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
arr = np. reshape(arr, (2, 5))
print(arr)
array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]])
x = [[0, 1, 2, 3, 4] , [5, 6, 7, 8, 9]]
arr_1 = np.array(x)
y = [[1, 1, 1, 1, 1] , [1, 1, 1, 1, 1]]
arr_2 = np.array(y)
np.vstack((arr_1,arr_2))
array([[0, 1, 2, 3, 4, 1, 1, 1, 1, 1], [5, 6, 7, 8, 9, 1, 1, 1, 1, 1]])
np.hstack((arr_1,arr_2))
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
print(arr.ndim,"Dimension") print(arr) arr = arr.flatten() print(arr.ndim,"Dimension") arr
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
arr = np.arange(15).reshape(-1) arr
array([[ 0, 1, 2], [ 3, 4, 5], [ 6, 7, 8], [ 9, 10, 11], [12, 13, 14]])
arr = np.arange(15).reshape(-1,3) arr
arr = np.arange(25).reshape(5,5) print(arr) np.square(arr)
np.random.seed(123) arr = np.random.randint(30,size = (5,6)) print(arr) arr.mean()
np.std(arr)
np.median(a)
arr.T
arr = np.arange(16).reshape(4,4) print(arr) np.diagonal(arr)
np.linalg.det(arr)
arr = np.arange(10) print(arr) print(np.percentile(arr,5)) print(np.percentile(arr,95))
empty_array= np.array print(array) is_empty = (empty_array) print(is_empty)