{"id":5469,"date":"2020-11-19T17:50:57","date_gmt":"2020-11-19T12:20:57","guid":{"rendered":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/?p=5469"},"modified":"2021-06-14T16:02:14","modified_gmt":"2021-06-14T10:32:14","slug":"numpy-axis","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/","title":{"rendered":"Numpy Axis in Python With Detailed Examples"},"content":{"rendered":"\n<p>Hello programmers, in today\u2019s article, we will discuss and explain the Numpy axis in python. Understanding the use of axes in a Numpy array is not very simple. But let&#8217;s start with this. The Numpy axis is very similar to axes in a cartesian coordinate system. Before we start with how Numpy axes, let me familiarize you with the Numpy axis concept a little more.<\/p>\n\n\n\n<p id=\"h-numpy-axis\"><strong>Numpy Axis is a type of direction through which the iteration starts. Every operation in numpy has a specific iteration process through which the operation proceeds. Moreover, there are two types of the iteration process: Column order and Fortran order. Column order helps through the column axis, and Fortran order helps through the row axis.<\/strong><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_22 counter-hierarchy ez-toc-transparent\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Numpy_Axis_Directions\" title=\"Numpy Axis Directions\">Numpy Axis Directions<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Ways_of_Implementing_Numpy_axis_in_Python\" title=\"Ways of Implementing Numpy axis in Python\">Ways of Implementing Numpy axis in Python<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Rows_and_Columns_for_Numpy_Array\" title=\"Rows and Columns for Numpy Array\">Rows and Columns for Numpy Array<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Numpy_Axis_in_Python_for_Sum\" title=\" Numpy Axis in Python for Sum\"> Numpy Axis in Python for Sum<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Numpy_Axis_for_Concatenation_of_two_Arrays\" title=\"Numpy Axis for Concatenation of two Arrays\">Numpy Axis for Concatenation of two Arrays<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#1D_Array_NP_Axis_in_Python_-_Special_Case\" title=\"1D Array NP Axis in Python &#8211; Special Case\">1D Array NP Axis in Python &#8211; Special Case<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 id=\"h-numpy-axis-directions\"><span class=\"ez-toc-section\" id=\"Numpy_Axis_Directions\"><\/span>Numpy Axis Directions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Axis 0 (Direction along Rows) <\/strong>&#8211; Axis 0 is called the first axis of the Numpy array. This axis 0 runs vertically downward along the rows of Numpy multidimensional arrays, i.e., performs <strong>column-wise<\/strong> operations.<\/p>\n\n\n\n<p><strong>Axis 1 (Direction along with<\/strong> columns) &#8211; Axis 1 is called the second axis of multidimensional Numpy arrays. As a result, Axis 1 sums horizontally along with the columns of the arrays. It performs row-wise<strong> <\/strong>operations.<\/p>\n\n\n\n<p><strong>NOTE:<\/strong> &nbsp;The above Numpy axis description is only for 2D and multidimensional arrays. It works differently for 1D arrays discussed later in this article.<\/p>\n\n\n\n<h2 id=\"h-ways-of-implementing-numpy-axis-in-python\"><span class=\"ez-toc-section\" id=\"Ways_of_Implementing_Numpy_axis_in_Python\"><\/span>Ways of Implementing Numpy axis in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul><li><strong>Rows and columns for Numpy Array.<\/strong><\/li><li><strong>Numpy axis for the sum.<\/strong><\/li><li><strong>Numpy axis to concatenate.<\/strong><\/li><li><strong>ID Array Numpy axis.<\/strong><\/li><\/ul>\n\n\n\n<h2 id=\"h-rows-and-columns-for-numpy-array\"><span class=\"ez-toc-section\" id=\"Rows_and_Columns_for_Numpy_Array\"><\/span>Rows and Columns for Numpy Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>EXAMPLE:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&lt;pre class=&quot;wp-block-syntaxhighlighter-code&quot;&gt;&lt;a href=&quot;https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-asarray\/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer noopener&quot;&gt;&lt;a href=&quot;https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-asarray\/&quot;  target=&quot;_blank&quot; rel=&quot;noreferrer noopener&quot;&gt;From numpy import asarray&lt;\/a&gt;&lt;\/a&gt;\ndata = &#91;&#91;1,2,3], &#91;4,5,6]]\n# convert to a numpy array\ndata = asarray(data)\n\n# step through rows\nfor row in range(data.shape&#91;0]):\n\tprint(data&#91;row, :])\n\n#step through columns\nfor col in range(data.shape&#91;1]):\n\tprint(data&#91;:, col])&lt;\/pre&gt;\n<\/pre><\/div>\n\n\n<p><strong>OUTPUT:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#91;1 2 3]\n&#91;4 5 6]\n\n&#91;1 4]\n&#91;2 5]\n&#91;3 6]\n<\/pre><\/div>\n\n\n<h3 id=\"h-explanation\"><strong>EXPLANATION<\/strong>:<\/h3>\n\n\n\n<p>In the above example, we are enumerating each row and column&#8217;s data. In other words, we are achieving this by accessing them through their index. The data[0, 0] gives the value at the first row and first column. Moreover, data[0, :] gives the values in the first row and all columns. E.g., the complete first row in our matrix. Similarly, data[:, 0] accesses all rows for the first column. Above all, printing the rows of the array, the Numpy axis is set to 0, i.e., data.shape[0]. Similarly, the Numpy axis is set to 1 while enumerating the columns.<\/p>\n\n\n\n<h2 id=\"h-numpy-axis-in-python-for-sum\"><span class=\"ez-toc-section\" id=\"Numpy_Axis_in_Python_for_Sum\"><\/span> Numpy Axis in Python for Sum<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When we use the <a href=\"https:\/\/www.pythonpool.com\/python-sum\/\" target=\"_blank\" rel=\"noreferrer noopener\">numpy sum()<\/a> function&nbsp;on a 2-d array with the&nbsp;<code>axis<\/code>&nbsp;parameter, it collapses the 2-d array down to a 1-d array. It collapses the data and reduces the number of dimensions. But which axis will collapse to return the sum depends on whether we set the axis to 0 or 1. Let&#8217;s have a look at the following examples for a better understanding.<\/p>\n\n\n\n<h3 id=\"h-numpy-sum-with-axis-0\">Numpy sum with axis 0<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n#creating Numpy Array\nnp_array_2d = np.arange(0, 6).reshape(&#91;2,3])\n\nprint(np_array_2d)\n\na = np.sum(np_array_2d, axis = 0)\nprint(a)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#91;&#91;0 1 2]\n &#91;3 4 5]]\n\narray(&#91;3, 5, 7])\n<\/pre><\/div>\n\n\n<h3 id=\"h-explanation-1\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>In the above example, we create an array of size(2,3), i.e., two rows and three columns. When the axis is set to 0. Immediately, the function actually sums down the columns. The result is a new NumPy array that contains the sum of each column. As discussed earlier, Axis 0 is the direction along rows but performs column-wise operations. Axis set to 0 refers to aggregating the data. Therefore we&nbsp;collapse&nbsp;the rows&nbsp;and perform the sum operation column-wise. Thus, the sum() function&#8217;s axis parameter represents which axis is to be collapsed.<\/p>\n\n\n\n<h3 id=\"h-numpy-sum-with-axis-1\">Numpy Sum With Axis 1<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n#creating Numpy Array\nnp_array_2d = np.arange(0, 6).reshape(&#91;2,3])\n\nprint(np_array_2d)\n\na = np.sum(np_array_2d, axis = 1)\nprint(a)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\narray(&#91;3, 12])\n<\/pre><\/div>\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<p>As we know, axis 1, according to the axis convention. For instance, it refers to the direction along columns performing operations over rows. For the sum() function. The axis parameter is the axis to be collapsed. Hence in the above example.  For instance, the axis is set to 1 in the sum()  function collapses the columns and sums down the rows.<\/p>\n\n\n\n<h2 id=\"h-numpy-axis-for-concatenation-of-two-arrays\"><span class=\"ez-toc-section\" id=\"Numpy_Axis_for_Concatenation_of_two_Arrays\"><\/span>Numpy Axis for Concatenation of two Arrays<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The <code>axis<\/code>&nbsp;the parameter we use with the numpy concatenate()&nbsp;function defines the axis along which we stack the arrays. We get different types of concatenated arrays depending upon whether the axis parameter value is set to 0 or 1. In addition, to have a clearer understanding of what is said, refer to the below examples.<\/p>\n\n\n\n<h3 id=\"h-concatenate-np-arrays-with-axis-0\">Concatenate Np arrays with axis 0<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n#arrays defined\nnp_array_1 = np.array(&#91;&#91;1,1,1],&#91;1,1,1]])\nnp_array_2 = np.array(&#91;&#91;2,2,2],&#91;2,2,2]])\n\nprint(np_array_1)\nprint(np_array_2)\n\na = np.concatenate(&#91;np_array_1, np_array_2], axis = 0)\n\nprint(a)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\narray(&#91;&#91;1, 1, 1],\n       &#91;1, 1, 1]])\n\narray(&#91;&#91;2, 2, 2],\n       &#91;2, 2, 2]])\n\narray(&#91;&#91;1, 1, 1],\n       &#91;1, 1, 1],\n       &#91;2, 2, 2],\n       &#91;2, 2, 2]])\n<\/pre><\/div>\n\n\n<h3 id=\"h-explanation-2\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>As already mentioned, the axis parameter in the <strong>&#8216;concatenate()&#8217; function implies stacking the arrays. So when we set the axis to 0, the concatenate function stacks the two arrays along the rows. We\u2019re specifying that we want concatenation of the arrays. The concatenation is done along axis 0, i.e., along the rows&#8217; direction<\/strong>. Thus we get the output as an array stacked. And two constituent arrays along rows.<\/p>\n\n\n\n<h3 id=\"h-concatenate-numpy-arrays-with-axis-1\">Concatenate Numpy arrays with axis 1<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n#arrays defined\nnp_array_1 = np.array(&#91;&#91;1,1,1],&#91;1,1,1]])\nnp_array_2 = np.array(&#91;&#91;2,2,2],&#91;2,2,2]])\n\nprint(np_array_1)\nprint(np_array_2)\n\na = np.concatenate(&#91;np_array_1, np_array_2], axis = 1)\n\nprint(a)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\narray(&#91;&#91;1, 1, 1],\n       &#91;1, 1, 1]])\n\narray(&#91;&#91;2, 2, 2],\n       &#91;2, 2, 2]])\n\narray(&#91;&#91;1, 1, 1, 2, 2, 2],\n       &#91;1, 1, 1, 2, 2, 2]])\n<\/pre><\/div>\n\n\n<h3 id=\"h-explanation-3\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>In the above example, the axis parameter is set to 1. For instance, we know, axis 1 specifies the direction along with columns.  Above all this implies the numpy concatenate() function to combine two input <a href=\"https:\/\/en.wikipedia.org\/wiki\/Array_data_structure\" target=\"_blank\" rel=\"noreferrer noopener\">arrays<\/a>. After that, the concatenation is done horizontally along with the columns.<\/p>\n\n\n\n<h2 id=\"h-1d-array-np-axis-in-python-special-case\"><span class=\"ez-toc-section\" id=\"1D_Array_NP_Axis_in_Python_-_Special_Case\"><\/span>1D Array NP Axis in Python &#8211; Special Case<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The numpy axes work differently for one-dimensional arrays. Most of the discussion we had in this article applies two-dimensional arrays with two axes &#8211; rows and columns. 1D arrays are different since it has only one axis. Numpy axes are numbered like Python indexes, i.e., they start at 0. Therefore in a 1D array, the first and&nbsp;only&nbsp;axis is axis 0. If we specify the axis parameter as 1 while working with 1D arrays.  In addition, it returns an error. <\/p>\n\n\n\n<h3 id=\"h-example-to-concatenate-two-1d-arrays-with-np-axis-in-python\">Example to concatenate two 1D arrays with Np axis in python<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as np\n\n#arrays defined\nnp_array_1 = np.array(&#91;1,1,1])\nnp_array_2 = np.array(&#91;&#91;2,2,2])\n\nprint(np_array_1)\nprint(np_array_2)\n\na = np.concatenate(&#91;np_array_1, np_array_2], axis = 0)\n\nb = np.concatenate(&#91;np_array_1, np_array_2], axis = 1)\n\n\nprint(a)\n\nprint(b)\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&#91;1 1 1]\n\n&#91;2 2 2]\n\narray(&#91;1, 1, 1, 2, 2, 2])\n\nIndexError: axis 1 out of bounds &#91;0, 1)\n<\/pre><\/div>\n\n\n<h3 id=\"h-explanation-4\"><strong>Explanation:<\/strong><\/h3>\n\n\n\n<p>As mentioned above, 1-dimensional arrays only have one axis &#8211; Axis 0. The function is working properly when the axis parameter is set to 1. It prints &#8216;a&#8217; as a combined 1D array of the two input 1D arrays. In 1D arrays, axis 0 doesn\u2019t point along the rows  \u201cdownward\u201d as it does in a 2-dimensional array. However, when the axis parameter is set to 1, it could not print &#8216;b&#8217;. In conclusion, it raised an index error stating axis 1 is out of bounds for one-dimensional arrays.<\/p>\n\n\n\n<h2 id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In conclusion, we can say in this article, we have looked into Numpy axes in python in great detail. Numpy axis in python is used to implement various row-wise and column-wise operations. Operations like numpy sum(), <a href=\"https:\/\/www.pythonpool.com\/numpy-mean\/\" target=\"_blank\" rel=\"noreferrer noopener\">np mean()<\/a> and concatenate() are achieved by passing numpy axes as parameters. We can also enumerate data of the arrays through their rows and columns with the numpy axis&#8217;s help. Also, the special case of the axis for one-dimensional arrays is highlighted. This must be kept in mind while implementing python programs.<\/p>\n\n\n\n<p>However, if you have any doubts or questions do let me know in the comment section below. I will try to help you as soon as possible.<\/p>\n\n\n\n<p><strong><em>Happy Pythoning!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello programmers, in today\u2019s article, we will discuss and explain the Numpy axis in python. Understanding the use of axes in a Numpy array is &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Numpy Axis in Python With Detailed Examples\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/#more-5469\" aria-label=\"More on Numpy Axis in Python With Detailed Examples\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":5511,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1495],"tags":[2527,2528,2531,2529,1883,2530],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.1 (Yoast SEO v18.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Numpy Axis in Python With Detailed Examples - Python Pool<\/title>\n<meta name=\"description\" content=\"This article provides very brief idea of implementing numpy axis in python programs and special case of numpy axis for 1D arrays.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/numpy-axis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Numpy Axis in Python With Detailed Examples\" \/>\n<meta property=\"og:description\" content=\"Hello programmers, in today\u2019s article, we will discuss and explain the Numpy axis in python. Understanding the use of axes in a Numpy array is not very\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/numpy-axis\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-19T12:20:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T10:32:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Python Pool\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/c\/pythonpool\",\"https:\/\/twitter.com\/pythonpool\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png\",\"width\":1350,\"height\":650,\"caption\":\"numpy axis\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#webpage\",\"url\":\"https:\/\/www.pythonpool.com\/numpy-axis\/\",\"name\":\"Numpy Axis in Python With Detailed Examples - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage\"},\"datePublished\":\"2020-11-19T12:20:57+00:00\",\"dateModified\":\"2021-06-14T10:32:14+00:00\",\"description\":\"This article provides very brief idea of implementing numpy axis in python programs and special case of numpy axis for 1D arrays.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-axis\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Numpy Axis in Python With Detailed Examples\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/359166b9a432f7680dff9c50035fd1ab\"},\"headline\":\"Numpy Axis in Python With Detailed Examples\",\"datePublished\":\"2020-11-19T12:20:57+00:00\",\"dateModified\":\"2021-06-14T10:32:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#webpage\"},\"wordCount\":1084,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png\",\"keywords\":[\"numpy apply along axis\",\"numpy array axis\",\"numpy axis\",\"numpy axis 0\",\"numpy mean axis\",\"numpy sum axis\"],\"articleSection\":[\"Numpy\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-axis\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/359166b9a432f7680dff9c50035fd1ab\",\"name\":\"Python Pool\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g\",\"caption\":\"Python Pool\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Numpy Axis in Python With Detailed Examples - Python Pool","description":"This article provides very brief idea of implementing numpy axis in python programs and special case of numpy axis for 1D arrays.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/","og_locale":"en_US","og_type":"article","og_title":"Numpy Axis in Python With Detailed Examples","og_description":"Hello programmers, in today\u2019s article, we will discuss and explain the Numpy axis in python. Understanding the use of axes in a Numpy array is not very","og_url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/","og_site_name":"Python Pool","article_published_time":"2020-11-19T12:20:57+00:00","article_modified_time":"2021-06-14T10:32:14+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Python Pool","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/","sameAs":["https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.youtube.com\/c\/pythonpool","https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/twitter.com\/pythonpool"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png","contentUrl":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png","width":1350,"height":650,"caption":"numpy axis"},{"@type":"WebPage","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#webpage","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/","name":"Numpy Axis in Python With Detailed Examples - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage"},"datePublished":"2020-11-19T12:20:57+00:00","dateModified":"2021-06-14T10:32:14+00:00","description":"This article provides very brief idea of implementing numpy axis in python programs and special case of numpy axis for 1D arrays.","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Numpy Axis in Python With Detailed Examples"}]},{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#webpage"},"author":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#\/schema\/person\/359166b9a432f7680dff9c50035fd1ab"},"headline":"Numpy Axis in Python With Detailed Examples","datePublished":"2020-11-19T12:20:57+00:00","dateModified":"2021-06-14T10:32:14+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#webpage"},"wordCount":1084,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/11\/Theatre-Actor-Portfolio-Website-17.png","keywords":["numpy apply along axis","numpy array axis","numpy axis","numpy axis 0","numpy mean axis","numpy sum axis"],"articleSection":["Numpy"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/numpy-axis\/#respond"]}]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#\/schema\/person\/359166b9a432f7680dff9c50035fd1ab","name":"Python Pool","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/secure.gravatar.com\/avatar\/b170f9f39a7cad6ab2d2b1c4bc7b79f5?s=96&d=wavatar&r=g","caption":"Python Pool"}}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5469"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=5469"}],"version-history":[{"count":35,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5469\/revisions"}],"predecessor-version":[{"id":13610,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5469\/revisions\/13610"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/5511"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=5469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=5469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=5469"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20220519191620\/https:\/\/api.w.org\/{rel}","templated":true}]}}