{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"___\n",
"\n",
"\n",
"___\n",
"
\n", "arr.min() returns 0 minimum\n", "arr.var() returns 8.25 variance\n", "arr.std() returns 2.8722813232690143 standard deviation\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Axis Logic\n", "When working with 2-dimensional arrays (matrices) we have to consider rows and columns. This becomes very important when we get to the section on pandas. In array terms, axis 0 (zero) is the vertical axis (rows), and axis 1 is the horizonal axis (columns). These values (0,1) correspond to the order in which arr.shape values are returned.\n", "\n", "Let's see how this affects our summary statistic calculations from above." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 1, 2, 3, 4],\n", " [ 5, 6, 7, 8],\n", " [ 9, 10, 11, 12]])" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arr_2d = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])\n", "arr_2d" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([15, 18, 21, 24])" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "arr_2d.sum(axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By passing in axis=0, we're returning an array of sums along the vertical axis, essentially [(1+5+9), (2+6+10), (3+7+11), (4+8+12)]\n", "\n", "