<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python Numpy Arrays
In this Notebook, we learn how to build and solve systems of linear equations, and apply these techniques to solve practical problems.
Python is a general-purpose programming, but specialized features geared towards data analysis are available in various libraries, such as numpy. Numpy's main datastructure is the ndarray which supports opperations such as adding rows or columns of data in an element-wise fashion and performing math operations on multidimentionsl matrices. Numpy (and Nnarrays) are the subject of this notebook.
On the one hand, ndarrays are similar to lists in that they consist of a collection of items that can be accessed via indexes, but on the other hand, ndarrays are different from lists by being homogeneous and only containing objects of the same type (list can be heterogeneous). 
To work with ndarrays, we need to load the numpy library.
Step1:  We can create an ndarray by passing a list to the np.array() function
Step2:  To create an array with more than one dimension, we can pass a nested list to the np.array() function
Step3:  The parameters of an ndarray include the number of dimensions it has, the size of each dimension and the type of data it contains. We can check the dimensions of an ndarray with the shape attribute
Step4:  The output above shows that array2 is a 2-dimensional array with 2 rows and 5 columns. We can check the size (total number of items) of an array with the size attribute and the type of the data it contains with the dtype attribute
Step5:  Numpy has several functions for creating arrays, such as
Step6:  np.eye() to create a 2d array with 1's across a specified diagonal and 0's everywhere else
Step7:  Array Indexing and Slicing
Numpy ndarrays offer numbered indexing and slicing syntax that mirrors the syntax for Python lists
Step8:  If an ndarray has more than one dimension, separate indexes for each dimension with a comma
Step9:  Reshaping Arrays
Rnp.reshape() reshapes an array into a new one with the same data but different structure
Step10:  Unravel a multi-dimensional into 1 dimension with np.ravel()
Step11:  Array Math Operations
Numpy arrays can perform mathematical operations easily using math operators like +, -, / and *
Step12:  One can also use the basic math operators on two arrays with the same shape. The basic math operators function in an element-wise fashion, returning an array with the same shape as the original.
Step13:  Numpy also provides math functions for ndarrays such as
Step14:  T np.dot() returns the dot product of two arrays.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
Explanation: Python Numpy Arrays
In this Notebook, we learn how to build and solve systems of linear equations, and apply these techniques to solve practical problems.
Python is a general-purpose programming, but specialized features geared towards data analysis are available in various libraries, such as numpy. Numpy's main datastructure is the ndarray which supports opperations such as adding rows or columns of data in an element-wise fashion and performing math operations on multidimentionsl matrices. Numpy (and Nnarrays) are the subject of this notebook.
On the one hand, ndarrays are similar to lists in that they consist of a collection of items that can be accessed via indexes, but on the other hand, ndarrays are different from lists by being homogeneous and only containing objects of the same type (list can be heterogeneous). 
To work with ndarrays, we need to load the numpy library.
End of explanation
list1 = [1, 2, 3, 4, 5]          # Define a list
array1 = np.array(list1)         # Pass the list to np.array()
type(array1)                     # Check the object's type
print("array1 = ", array1)       # Check the content of the array (printing in Python 3)
print ("array1 = %s" % np.array_str(array1)) # Check the content of the array (printing in Python 2)
Explanation: We can create an ndarray by passing a list to the np.array() function:
End of explanation
list2 = [[1,2,3,4,5], [6,7,8,9,10]]
array2 = np.array(list2)
print("array2 = ", array2)       # Python 3
print("array2 = %s" % np.array_str(array2))   # Python 2 and 3
Explanation: To create an array with more than one dimension, we can pass a nested list to the np.array() function:
End of explanation
array2.shape
Explanation: The parameters of an ndarray include the number of dimensions it has, the size of each dimension and the type of data it contains. We can check the dimensions of an ndarray with the shape attribute:
End of explanation
print("array2 has", array2.size ,"items of type", array2.dtype)             # Python 3
print ("array2 has %d items of type %s" % (array2.size, array2.dtype))      # Python 2 and 3
Explanation: The output above shows that array2 is a 2-dimensional array with 2 rows and 5 columns. We can check the size (total number of items) of an array with the size attribute and the type of the data it contains with the dtype attribute:
End of explanation
np.identity(n = 3)      # n is the size of the square 2-d array
Explanation: Numpy has several functions for creating arrays, such as:
np.identity(), to create a square 2d array with 1's across the diagonal and 0's everywhere else
End of explanation
np.eye(3,  # Number of rows
       5,  # Number of columns
       1)  # Index of the diagonal (main diagonal, 0, is the default)
# np.ones() to create an array filled with ones:
np.ones(shape= [2,3])
# np.zeros() to create an array filled with zeros:
np.zeros(shape= [3,4])
Explanation: np.eye() to create a 2d array with 1's across a specified diagonal and 0's everywhere else
End of explanation
d_array = np.array([1,2,3,4,5,6])
d_array[2] # Get the item at index 2
d_array[4:]       # Get a slice from index 3 to the end
d_array[::-1]     # shortcut to reverse the array
Explanation: Array Indexing and Slicing
Numpy ndarrays offer numbered indexing and slicing syntax that mirrors the syntax for Python lists:
End of explanation
# Create a new two dimensional array
dd_array = np.array([d_array, d_array + 10, d_array + 100])
print(dd_array) 
# Get the element on row 2, and column 3
dd_array[2, 3]
# Slice elements starting at row 1, and column 3
dd_array[1:, 4:]
#Reverse the array in both dimensions (rotation)
dd_array[::-1, ::-1]
Explanation: If an ndarray has more than one dimension, separate indexes for each dimension with a comma:
End of explanation
np.reshape(dd_array,        # Array to reshape
           newshape=(2,9))  # Dimensions of the new array
Explanation: Reshaping Arrays
Rnp.reshape() reshapes an array into a new one with the same data but different structure:
End of explanation
np.ravel(dd_array,          # Array to reshape
         order='C')         # Unravel by rows
np.ravel(dd_array,
         order='F')         # Unravel by columns
dd_array.flatten()       #flatten a multi-dimensional array into 1 dimension and return a copy of the result
dd_array.T  #get the transpose 
np.flipud(dd_array) #Flip an array vertically 
np.fliplr(dd_array) #Flip an array horizontally
np.rot90(dd_array,    # Rotate the array 90 degrees counter-clockwise 
         k=1)         # Number of 90 degree rotations
np.roll(dd_array,   # Shift elements in an array along a given dimension
        shift = 2,        # Shift elements 2 positions
        axis = 1)         # In each row
np.roll(dd_array,   #Leave the axis argument empty to shift across all dimensions
        shift = 2)
#Join arrays along an axis 
array_to_join = np.array([[10,20,30],[40,50,60],[70,80,90]])
np.concatenate((dd_array,array_to_join),      # Arrays to join
               axis=1)                        # Axis to join upon
Explanation: Unravel a multi-dimensional into 1 dimension with np.ravel():
End of explanation
dd_array + 10    # Add 10 to each element
dd_array - 10    # Subtract 10 from each element
dd_array * 2      # Multiply each element by 2
dd_array ** 2      # Square each element
Explanation: Array Math Operations
Numpy arrays can perform mathematical operations easily using math operators like +, -, / and *
End of explanation
array3 = np.array([[1,2],[3,4]])
array3 + array3
array3 - array3
array3 * array3
Explanation: One can also use the basic math operators on two arrays with the same shape. The basic math operators function in an element-wise fashion, returning an array with the same shape as the original.
End of explanation
np.mean(dd_array) # The mean of all the elements in an array 
np.std(dd_array)   #Get the standard deviation all the elements in an array 
 np.sum(dd_array, 
       axis=1)        # Get the row sums for the elements of an array 
np.sum(dd_array,
       axis=0)        # Get the column sums
np.sqrt(dd_array) # Take the square root of each element in the array
Explanation: Numpy also provides math functions for ndarrays such as:
End of explanation
np.dot(dd_array[0,0:],  # Slice row 0
       dd_array[1,0:])  # Slice row 1
Explanation: T np.dot() returns the dot product of two arrays.
End of explanation
<END_TASK>