<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <a href='http
Step1:  NumPy has many built-in functions and capabilities. We won't cover them all but instead we will focus on some of the most important aspects of NumPy
Step2:  Built-in Methods
There are lots of built-in ways to generate arrays.
arange
Return evenly spaced values within a given interval. [reference]
Step3:  zeros and ones
Generate arrays of zeros or ones. [reference]
Step4:  linspace
Return evenly spaced numbers over a specified interval. [reference]
Step5:  <font color=green>Note that .linspace() includes the stop value. To obtain an array of common fractions, increase the number of items
Step6:  eye
Creates an identity matrix [reference]
Step7:  Random
Numpy also has lots of ways to create random number arrays
Step8:  randn
Returns a sample (or samples) from the "standard normal" distribution [σ = 1]. Unlike rand which is uniform, values closer to zero are more likely to appear. [reference]
Step9:  randint
Returns random integers from low (inclusive) to high (exclusive).  [reference]
Step10:  seed
Can be used to set the random state, so that the same "random" results can be reproduced. [reference]
Step11:  Array Attributes and Methods
Let's discuss some useful attributes and methods for an array
Step12:  Reshape
Returns an array containing the same data with a new shape. [reference]
Step13:  max, min, argmax, argmin
These are useful methods for finding max or min values. Or to find their index locations using argmin or argmax
Step14:  Shape
Shape is an attribute that arrays have (not a method)
Step15:  dtype
You can also grab the data type of the object in the array
<ASSISTANT_TASK:>
Python Code:
import numpy as np
Explanation: <a href='http://www.pieriandata.com'><img src='../Pierian_Data_Logo.png'/></a>
<center><em>Copyright Pierian Data</em></center>
<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>
NumPy
NumPy is a powerful linear algebra library for Python. What makes it so important is that almost all of the libraries in the <a href='https://pydata.org/'>PyData</a> ecosystem (pandas, scipy, scikit-learn, etc.) rely on NumPy as one of their main building blocks. Plus we will use it to generate data for our analysis examples later on!
NumPy is also incredibly fast, as it has bindings to C libraries. For more info on why you would want to use arrays instead of lists, check out this great StackOverflow post.
We will only learn the basics of NumPy. To get started we need to install it!
Installation Instructions
NumPy is already included in your environment! You are good to go if you are using the course environment!
For those not using the provided environment:
It is highly recommended you install Python using the Anaconda distribution to make sure all underlying dependencies (such as Linear Algebra libraries) all sync up with the use of a conda install. If you have Anaconda, install NumPy by going to your terminal or command prompt and typing:
conda install numpy
If you do not have Anaconda and can not install it, please refer to Numpy's official documentation on various installation instructions.
Using NumPy
Once you've installed NumPy you can import it as a library:
End of explanation
my_list = [1,2,3]
my_list
np.array(my_list)
my_matrix = [[1,2,3],[4,5,6],[7,8,9]]
my_matrix
np.array(my_matrix)
Explanation: NumPy has many built-in functions and capabilities. We won't cover them all but instead we will focus on some of the most important aspects of NumPy: vectors, arrays, matrices and number generation. Let's start by discussing arrays.
NumPy Arrays
NumPy arrays are the main way we will use NumPy throughout the course. NumPy arrays essentially come in two flavors: vectors and matrices. Vectors are strictly 1-dimensional (1D) arrays and matrices are 2D (but you should note a matrix can still have only one row or one column).
Let's begin our introduction by exploring how to create NumPy arrays.
Creating NumPy Arrays
From a Python List
We can create an array by directly converting a list or list of lists:
End of explanation
np.arange(0,10)
np.arange(0,11,2)
Explanation: Built-in Methods
There are lots of built-in ways to generate arrays.
arange
Return evenly spaced values within a given interval. [reference]
End of explanation
np.zeros(3)
np.zeros((5,5))
np.ones(3)
np.ones((3,3))
Explanation: zeros and ones
Generate arrays of zeros or ones. [reference]
End of explanation
np.linspace(0,10,3)
np.linspace(0,5,20)
Explanation: linspace
Return evenly spaced numbers over a specified interval. [reference]
End of explanation
np.linspace(0,5,21)
Explanation: <font color=green>Note that .linspace() includes the stop value. To obtain an array of common fractions, increase the number of items:</font>
End of explanation
np.eye(4)
Explanation: eye
Creates an identity matrix [reference]
End of explanation
np.random.rand(2)
np.random.rand(5,5)
Explanation: Random
Numpy also has lots of ways to create random number arrays:
rand
Creates an array of the given shape and populates it with random samples from a uniform distribution over [0, 1). [reference]
End of explanation
np.random.randn(2)
np.random.randn(5,5)
Explanation: randn
Returns a sample (or samples) from the "standard normal" distribution [σ = 1]. Unlike rand which is uniform, values closer to zero are more likely to appear. [reference]
End of explanation
np.random.randint(1,100)
np.random.randint(1,100,10)
Explanation: randint
Returns random integers from low (inclusive) to high (exclusive).  [reference]
End of explanation
np.random.seed(42)
np.random.rand(4)
np.random.seed(42)
np.random.rand(4)
Explanation: seed
Can be used to set the random state, so that the same "random" results can be reproduced. [reference]
End of explanation
arr = np.arange(25)
ranarr = np.random.randint(0,50,10)
arr
ranarr
Explanation: Array Attributes and Methods
Let's discuss some useful attributes and methods for an array:
End of explanation
arr.reshape(5,5)
Explanation: Reshape
Returns an array containing the same data with a new shape. [reference]
End of explanation
ranarr
ranarr.max()
ranarr.argmax()
ranarr.min()
ranarr.argmin()
Explanation: max, min, argmax, argmin
These are useful methods for finding max or min values. Or to find their index locations using argmin or argmax
End of explanation
# Vector
arr.shape
# Notice the two sets of brackets
arr.reshape(1,25)
arr.reshape(1,25).shape
arr.reshape(25,1)
arr.reshape(25,1).shape
Explanation: Shape
Shape is an attribute that arrays have (not a method):  [reference]
End of explanation
arr.dtype
arr2 = np.array([1.2, 3.4, 5.6])
arr2.dtype
Explanation: dtype
You can also grab the data type of the object in the array: [reference]
End of explanation
<END_TASK>