<jupyter_start><jupyter_text>NumpyNumpy is linear algebra library for python, the reason it is so important for data science with python is that almost all of the libraries in the PyData Ecosystem rely on NumPy as one the main building block. NumPy is also incredibly fast, as it has bindings to C libraries. NumPy arrays essentialy  come in two flavous: vector, matrices. **Conda install numpy****pip install numpy**<jupyter_code>import numpy as np
# Creating numpy as array
my_list = [1,2,3]
arr = np.array(my_list)
arr
my_mat = [[1,2,3],[4,5,6],[7,8,9]]
np.array(my_mat)
np.arange(0,10,2)
np.zeros(4)
np.zeros((2,2))
np.ones(4)
np.ones((3,3))
np.linspace(0,10,10)
np.eye(4)
np.random.rand(10) # RANDOM SAMPLE FROM UNIFORM DISTRIBUTION
np.random.randn(3) # Normal distribution
np.random.randn(3,3)
np.random.randint(1,100,10)
arr = np.arange(25)
arr
ranarr = np.random.randint(0,50,100)
ranarr
arr.reshape(5,5)
arr.max(), arr.min(), arr.mean()
arr.argmax(), arr.argmin() # location of max / min
arr = arr.reshape(5,5)
arr.shape
arr.dtype<jupyter_output><empty_output><jupyter_text>Numpy Indexing and SelectionIndexing starts at 0 in python<jupyter_code>arr = np.arange(0,11)
arr
arr[5]
arr[0:5]
arr[5:]
arr[0:5] = 100
arr
arr = np.arange(0,11)
arr
slice_of_arr = arr[:5]
slice_of_arr
arr_copy = arr.copy()
arr_copy
arr_2d = np.array([[5,10,15],[20,25,30],[35,40,45]])
arr_2d
arr_2d[0][0]
arr_2d[0]
arr_2d[1]
arr_2d[1,2]
arr_2d[0:,1]
arr = np.arange(1,11)
arr
bool_arr = arr>5
bool_arr
arr[bool_arr]
arr[arr>5]
 arr[arr<3]
arr_2d = np.arange(50).reshape(5,10)
arr_2d[1,3:5]<jupyter_output><empty_output><jupyter_text>Numpy operations* Array with Array* Array with Scalar* Universal Array Functions<jupyter_code>arr = np.arange(0,11)
arr + arr
arr - arr
arr * arr
arr * 8
arr + 104
arr / arr
1 / arr
arr ** 2
np.sqrt(arr)
np.exp(arr)
np.max(arr)
arr.max()
np.sin(arr)
np.log(arr)<jupyter_output>/home/sudhir/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:1: RuntimeWarning: divide by zero encountered in log
  """Entry point for launching an IPython kernel.<jupyter_text>NumPy Exercise Overview<jupyter_code>np.zeros(10)
np.ones(10)
np.arange(10,51)
np.arange(10,51,2)
np.arange(0,9).reshape(3,3)
np.random.rand(1)
np.random.randn(25).reshape(5,5)
np.arange(0.01,1,0.01)
np.linspace(0,1,20)
mat = np.arange(1,26).reshape(5,5)
mat
mat[2:4,1:3]
mat[2:,1:]
mat[3,4]
mat[4,:]
mat.sum()
mat.std()
mat.mean()
mat.sum(axis=0)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1629418935392117, 'fraction_numerical': 0.07192198293376677, 'mean_word_length': 6.115606936416185, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '130775', 'license': 'MIT', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1087, 'n_words': 230, 'path': 'Machine_Learning_Bootcamp/Python-for-Data-Analysis/NumPy/Numpy.ipynb', 'repo_name': 'sudhirln92/data-science-courses', 'size': '2461'}