When conducting an analysis, we often need to find the mean, standard deviation and minimum/maximum values.
Let's start with a 2D array, which is the most common for data analysis.
Use .mean
to find the mean of elements in an array. You can find the mean of all elements, or find the mean of elements in rows or columns by specifying the axis.
Now let's verify the information above:
Use np.sum
to sum all elements in the matrix. You can also specify the axis to sum by rows or columns.
Use np.std
to find the standard deviation of all elements in the matrix. You can also specify the axis to find the standard deviation of rows or columns.
Use .min
and .max
to find the minimum and maximum of the entire matrix. You can also specify the axis for rows and columns.
Use this array for the following practice:
myArray = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
1. Find the mean of this array
2. Find the standard deviation by rows
3. Find the maximum value in the array