<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 NumPy
NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
In this notebook we'll try various numpy methods and in the process learn more about NumPy.
Installation
Please follow this link
Importing NumPy
Once numpy is installed, we can import it in our file
Step1:  NumPy Arrays
In NumPy, strictly 1-D arrays are known as vectors and 2-D arrays are known as matrices (a matrix can also have only one row or one column). With NumPy arrays we can get access to various pre-written functions from NumPy.
Creating NumPy Arrays
There are various ways to create NumPy Arrays. Some of them are listed below.
From a Python List
Step2:  arange method
arange ( starting_number, ending_number_plus_one, step? )
Returns evenly spaced values within a given interval. step is optional
Step3:  zeros method
zeros ( shape )
Returns a new array of given shape and type, filled with zeros.
Step4:  ones method
ones ( shape )
Returns a new array of given shape and type, filled with ones.
Step5:  linspace
linspace ( starting_number, ending_number, number_of_elements_in_array )
Returns evenly spaced numbers over a specified interval.
Step6:  eye
eye ( number_of_rows )
Returns a 2-D array with ones on the diagonal and zeros elsewhere. (Returns and identity matrix)
Step7:  Random
rand
rand( shape )
Returns random values in a given shape.
Step8:  randn
randn ( shape )
Returns a sample (or samples) from the "standard normal" distribution.
Step9:  randint
randint( low, high?, size? )
Returns random integers from low (inclusive) to high (exclusive).
Step10:  Array Attributes
max, min, argmax, argmin
Step11:  Reshape, Shape and Ravel
reshape
reshape ( shape )
Returns an array containing the same data with a new shape.
Step12:  Shape
Its an attribute which returns the shape (in a tuple) of the array.
Step13:  ravel
ravel ( )
Returns a flattened array. (does not return a new copy)
Step14:  flatten
flatten ( )
Returns a copy of the array collapsed into one dimension.
Step15:  dtype
Its an attribute which returns the data type of the object
Step16:  Selection
index-based selection
For normal 1-D lists
Step17:  For multi dimensional lists
Step18:  comparison selectors
Step19:  Universal Functions
NumPy comes with many universal functions. Some of it are in the next cells.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
Explanation: NumPy
NumPy is a library for the Python programming language, adding support for large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.
In this notebook we'll try various numpy methods and in the process learn more about NumPy.
Installation
Please follow this link
Importing NumPy
Once numpy is installed, we can import it in our file
End of explanation
list = ['a', 'b', 'c', 'd']
list
np.array(list)
list_matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
list_matrix
np.array(list_matrix)
Explanation: NumPy Arrays
In NumPy, strictly 1-D arrays are known as vectors and 2-D arrays are known as matrices (a matrix can also have only one row or one column). With NumPy arrays we can get access to various pre-written functions from NumPy.
Creating NumPy Arrays
There are various ways to create NumPy Arrays. Some of them are listed below.
From a Python List
End of explanation
np.arange(1, 11)
np.arange(5, 60, 5)
Explanation: arange method
arange ( starting_number, ending_number_plus_one, step? )
Returns evenly spaced values within a given interval. step is optional
End of explanation
np.zeros(10)
np.zeros((5, 5))
Explanation: zeros method
zeros ( shape )
Returns a new array of given shape and type, filled with zeros.
End of explanation
np.ones(10)
np.ones((5,5))
Explanation: ones method
ones ( shape )
Returns a new array of given shape and type, filled with ones.
End of explanation
np.linspace(10, 20, 5)
np.linspace(100, 101, 10)
Explanation: linspace
linspace ( starting_number, ending_number, number_of_elements_in_array )
Returns evenly spaced numbers over a specified interval.
End of explanation
np.eye(4)
Explanation: eye
eye ( number_of_rows )
Returns a 2-D array with ones on the diagonal and zeros elsewhere. (Returns and identity matrix)
End of explanation
np.random.rand(5)
np.random.rand(3,3)
np.random.rand(2,3,4)
Explanation: Random
rand
rand( shape )
Returns random values in a given shape.
End of explanation
np.random.randn(3)
np.random.randn(4,4)
Explanation: randn
randn ( shape )
Returns a sample (or samples) from the "standard normal" distribution.
End of explanation
np.random.randint(5)
np.random.randint(1,11)
np.random.randint(1, 100, 10)
np.random.randint(1, 100, (4, 4))
Explanation: randint
randint( low, high?, size? )
Returns random integers from low (inclusive) to high (exclusive).
End of explanation
list = np.arange(1,10)
list.max()
list.min()
list.argmax()
list.argmin()
Explanation: Array Attributes
max, min, argmax, argmin
End of explanation
reshape_list = np.arange(1,10)
reshape_list
reshape_list.reshape(3,3)
Explanation: Reshape, Shape and Ravel
reshape
reshape ( shape )
Returns an array containing the same data with a new shape.
End of explanation
shape_list = np.arange(1,10)
shape_list
shape_list.shape
shape_list.reshape(3,3)
shape_list.reshape(3,3).shape
Explanation: Shape
Its an attribute which returns the shape (in a tuple) of the array.
End of explanation
ravel_list = np.arange(1,26).reshape(5,5)
ravel_list
ravel_list = ravel_list.ravel()
ravel_list
Explanation: ravel
ravel ( )
Returns a flattened array. (does not return a new copy)
End of explanation
flatten_list = np.arange(1,26).reshape(5,5)
flatten_list
flatten_list = flatten_list.flatten()
flatten_list
Explanation: flatten
flatten ( )
Returns a copy of the array collapsed into one dimension.
End of explanation
list = np.arange(1,11)
list.dtype
list = np.array(['a', 'b', 'c'])
list.dtype
Explanation: dtype
Its an attribute which returns the data type of the object
End of explanation
selection_list = np.arange(1,26)
selection_list
selection_list[9]
selection_list[24]
Explanation: Selection
index-based selection
For normal 1-D lists
End of explanation
selection_list = selection_list.reshape(5, 5)
selection_list
selection_list[2:,1:]
selection_list[1:4,2:4]
Explanation: For multi dimensional lists
End of explanation
selection_list = selection_list.ravel()
selection_list
selection_list[selection_list>10]
Explanation: comparison selectors
End of explanation
uni_list = np.arange(1,11)
uni_list
np.square(uni_list)
np.sin(uni_list)
np.log(uni_list)
np.log10(uni_list)
np.isfinite(uni_list)
Explanation: Universal Functions
NumPy comes with many universal functions. Some of it are in the next cells.
End of explanation
<END_TASK>