<jupyter_start><jupyter_text>Fundametal of Numpy Numpy is linear algebra library for python .this is importent library because all pydata ecosystem rely on numpy.<jupyter_code>import numpy as np

arr = [1,2,3]
arr
np.array(arr)
my_mat = [[1,2,3],[4,5,6],[7,8,9]]

my_mat

np.array(my_mat)
my_mat[0][1]<jupyter_output><empty_output><jupyter_text>Arange<jupyter_code># np.arange(start , last , offset)

np.arange(0,10)  
np.arange(0,5,1)

np.arange(2,12,2)<jupyter_output><empty_output><jupyter_text>Zeros<jupyter_code># Zeros 

np.zeros(3)  # one dimensional
np.zeros((3,3))  # two dimensional<jupyter_output><empty_output><jupyter_text>One's<jupyter_code># one's

np.ones(5)
np.ones((2,2))<jupyter_output><empty_output><jupyter_text>linespace<jupyter_code># linspace -> (start , end , how many point u want in between start to end)

np.linspace(0,5,10)<jupyter_output><empty_output><jupyter_text>eye<jupyter_code># Diagonal element 

np.eye(3)<jupyter_output><empty_output><jupyter_text>Random Function<jupyter_code># random -> (number of points in between )

np.random.rand(5)

np.random.rand(3,3)    
# random based on standard normal distrubution

np.random.randn(3)

# random number between start to end anything in interger format

np.random.randint(1,20)
#  start , end , numbers of points in between 
np.random.randint(1,20,5)<jupyter_output><empty_output><jupyter_text>Reshape<jupyter_code># reshape

# we can reshape the arr into 2 dimesional
# we can't resize 10 into 2 row and 3 column or anything we have to reshape into row 2 and column 5
                
array = np.arange(10)
array.reshape(2,5)<jupyter_output><empty_output><jupyter_text>Random<jupyter_code>number = np.random.randint(1,20,5);
print(number.max())
print(number.min())
print(number.argmax())  # return location where max is stored
print(number.argmin())  # return location where min is stored<jupyter_output>17
2
0
2<jupyter_text>Shape<jupyter_code>array.shape  #because its one dimesional<jupyter_output><empty_output><jupyter_text>dtype<jupyter_code># type
array.dtype

# instead of writing like these -> np.random.randint(1,20)
from numpy.random import randint

# then we can directly call randint which will return random number in between 3 to 10 
randint(3,10)
arr_1 = np.arange(1,20)<jupyter_output><empty_output><jupyter_text>mathematical operator<jupyter_code>arr_1 
arr_1 + arr_1
arr_1 * arr_1
arr_1 - arr_1
arr_1 / arr_1
arr_1*10
arr_1**2
np.square(arr_1)
np.max(arr_1)
np.sqrt(arr_1)
np.exp(arr_1)
# mathematical operator
np.sin(arr_1)
np.log(arr_1)<jupyter_output><empty_output><jupyter_text>Numpy indexing and selection<jupyter_code>arr_2d = np.array([+.
                   [5,10,15],[20,23,45],[78,54,12]])

arr_2d
arr_2d[0][1]
#Grab Everything from row 2 which is starting from column 1 to onwords
arr_2d[:2,1:]

arr_2d[1,1:]
boolean = arr_2d > 30
boolean
arr_2d[boolean]  
arr_2d[arr_2d>20]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.125128556736373, 'fraction_numerical': 0.04696606102159753, 'mean_word_length': 6.3686868686868685, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '260575', 'license': 'MIT', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1175, 'n_words': 237, 'path': 'machine_learning/02-Fundamentals of Numpy.ipynb', 'repo_name': 'imkaran23/Jupyter', 'size': '2917'}