{"id":3772,"date":"2020-07-31T15:06:10","date_gmt":"2020-07-31T09:36:10","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=3772"},"modified":"2021-06-14T15:00:26","modified_gmt":"2021-06-14T09:30:26","slug":"numpy-mean","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/numpy-mean\/","title":{"rendered":"Numpy Mean: Implementation and Importance"},"content":{"rendered":"\n<p>In statistics, three of the most important operations is to find the<strong> mean, median, and mode of the given data<\/strong>. Lots of insights can be taken when these values are calculated.<strong> Mean is the average of the data<\/strong>. Median is the middle number after arranging the data in sorted order, and mode is the value that has occurred the most number of times. In this article, we will study about mean, what its importance is, and how it can be calculated using <em>numpy mean()<\/em> function.<\/p>\n\n\n\n<p><strong>Numpy Mean is a powerful method to compute the average of values within an array. This inbuilt method is built on a better algorithmic approach and works very fast. Most importantly, it supports multiple dimensional computations of mean.<\/strong><\/p>\n\n\n\n<p>Mean = (Sum of all the terms)\/(Total number of terms)<br>For example, if we have 5 numbers- 2,4,6,1,9<br>Mean = (2+4+6+1+9)\/(5)<br>Mean= ( 22 \/ 5 ) = 4.4<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><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-mean\/#Syntax_of_Numpy_Mean\" >Syntax of Numpy Mean<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#Parameters\" >Parameters-<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#Return_Type\" >Return Type-<\/a><\/li><\/ul><\/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-mean\/#Calculating_mean_using_Numpy_Mean\" >Calculating mean using Numpy Mean<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#1_Without_any_additional_arguments\" >1. Without any additional arguments.&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#2_Using_axis_parameter\" >2. Using axis parameter<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#3_Changing_the_dtype\" >3. Changing the dtype<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#4_Storing_the_output_in_another_array\" >4. Storing the output in another array<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#Applications_of_numpy_mean_in_statistics\" >Applications of numpy mean in statistics<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#a_Mean_Squared_Error\" >a. Mean Squared Error<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#b_Filling_Nan_values_using_numpy_mean\" >b. Filling Nan values using numpy mean<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#Must_Read\" >Must Read:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#Conclusion\" >Conclusion-<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-syntax-of-numpy-mean\"><span class=\"ez-toc-section\" id=\"Syntax_of_Numpy_Mean\"><\/span>Syntax of Numpy Mean<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Numpy module is used to perform fast operations on arrays. To use it, we first need to install it in our system using \u2013<strong>pip install numpy<\/strong>.<br>Inside the numpy module, we have a function called<strong> mean(),<\/strong> which can be used to calculate the given data points arithmetic mean.<\/p>\n\n\n\n<p><strong>Numpy.mean(arr, axis=None, dtype=None, out=None)<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-parameters\"><span class=\"ez-toc-section\" id=\"Parameters\"><\/span>Parameters-<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>arr<\/strong>: It is the array of whose mean we want to find. The elements must be either <strong>integer or floating-point <\/strong>values. Even if arr is not an array, it automatically converts it into array type.<\/p>\n\n\n\n<p><strong>axis:<\/strong> It is the axes along which the mean is calculated. When<strong> no value<\/strong> is given, the mean is calculated along with the <strong>flattened array<\/strong>.<br>If <strong>axis = 0, the mean is calculated along with the columns<\/strong>.<br>If <strong>axis=1, the mean is calculated along the rows.<\/strong><br>We will understand more about this axis parameter when we will be making programs.<\/p>\n\n\n\n<p><strong>dtype<\/strong>: It is the data type, whose value we desire. <strong>By default, the value is float<\/strong>. If we want our output to be an integer, we have to give value as an int.<\/p>\n\n\n\n<p><strong>Out<\/strong>: If we want our output to be stored in an array, we can give that array in this argument. The dimensions of that array should be the same as that of the output that is going to come. This is an optional parameter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-return-type\"><span class=\"ez-toc-section\" id=\"Return_Type\"><\/span>Return Type-<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>By default, the value of the output is float, but we can change it to an integer as well.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-calculating-mean-using-numpy-mean\"><span class=\"ez-toc-section\" id=\"Calculating_mean_using_Numpy_Mean\"><\/span>Calculating mean using Numpy Mean<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us now jump to the coding part. We will see how does each parameter affects our output. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-1-without-any-additional-arguments\"><span class=\"ez-toc-section\" id=\"1_Without_any_additional_arguments\"><\/span>1. Without any additional arguments.&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\na = &#x5B;10,20,11,320]\n# list will automatically convert into array\nprint(numpy.mean(a))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">Output-\n90.25<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\narr = &#x5B;&#x5B;10,20,30],&#x5B;50,60,70],&#x5B;40,80,90]]\n# as we are not giving axis so we are getting mean of whole array as a single output. \nprint(numpy.mean(arr))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">50.0<\/pre>\n\n\n\n<p>Here we are getting output as 50 because <strong>(10+20+30+50+60+70+40+80+90)\/9 = 50.0<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-using-axis-parameter\"><span class=\"ez-toc-section\" id=\"2_Using_axis_parameter\"><\/span>2. Using axis parameter<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\narr = &#x5B;&#x5B;10,20,30],&#x5B;50,60,70],&#x5B;40,80,90]]\n# column wise elements are taken\nprint(numpy.mean(arr,axis=0))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">array([33.33333333, 53.33333333, 63.33333333])<\/pre>\n\n\n\n<p>Here, as we have given axis=0, it is taking elements column wise.<\/p>\n\n\n\n<p>(10+50+40)\/3=33.333333<\/p>\n\n\n\n<p>(20+60+80)\/3 = 53.33333333<\/p>\n\n\n\n<p>(30+70+90)\/3 = 63.33333333<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\narr = &#x5B;&#x5B;10,20,30],&#x5B;50,60,70],&#x5B;40,80,90]]\n# row wise elements are taken\nprint(numpy.mean(arr,axis=1))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">[20. 60. 70.]<\/pre>\n\n\n\n<p>Elements taken in order of rows. (10 + 20 + 30 ) \/ 3 = 20.0 , (50+60+70 ) \/ 3 = 60.0 , (40+80+90) \/ 3 = 70.0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-changing-the-dtype\"><span class=\"ez-toc-section\" id=\"3_Changing_the_dtype\"><\/span>3. Changing the dtype<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>By default, the output is in the form of float. Let us change it into integer type.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\narr = &#x5B;&#x5B;10,20,30,80],&#x5B;50,60,70,20],&#x5B;40,80,90,100]]\n# for integer the dtype is 'int'\nprint(numpy.mean(arr,axis=1,dtype=int))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">[35 50 77]<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-4-storing-the-output-in-another-array\"><span class=\"ez-toc-section\" id=\"4_Storing_the_output_in_another_array\"><\/span>4. Storing the output in another array<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Let us see how to store the output in another array.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy\narr = &#x5B;&#x5B;10,20,30,80],&#x5B;50,60,70,20],&#x5B;40,80,90,100]]\n# making an array of shape -4\nout_arr=np.arange(4)\nnumpy.mean(arr,axis=0,out=out_arr)\nprint(out_arr)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">[33 53 63 66]<\/pre>\n\n\n\n<p>You must be wondering that why we took the shape 4 and how will we know what shape the output array should be. The answer to that is simple. Here, we have given axis as 1 and<strong> axis=1 signifies that we want column-wise<\/strong> operations. And the number of columns = 4. So we have given the size of the output array as 4. We can also check it using the<strong> numpy.array().shape<\/strong> attribute. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\narr = &#x5B;&#x5B;10,20,30,80],&#x5B;50,60,70,20],&#x5B;40,80,90,100]]\nprint(numpy.array(&#x5B;&#x5B;10,20,30,80],&#x5B;50,60,70,20],&#x5B;40,80,90,100]]).shape)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">(3, 4)<\/pre>\n\n\n\n<p>Row=3, Columns = 4<\/p>\n\n\n\n<p>Let us do the same for axis=1.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy \narr = &#x5B;&#x5B;10,20,30,80],&#x5B;50,60,70,20],&#x5B;40,80,90,100]]\n# making an array of shape - 3\nout_arr=numpy.arange(numpy.array(arr).shape&#x5B;0])\nnumpy.mean(arr,axis=1,out=out_arr)\nprint(out_arr)\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">[35 50 77]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-applications-of-numpy-mean-in-statistics\"><span class=\"ez-toc-section\" id=\"Applications_of_numpy_mean_in_statistics\"><\/span>Applications of numpy mean in statistics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In the <a href=\"http:\/\/www.pythonpool.com\/data-science-internship\/\" >data science<\/a> world, the mean is a very important operation. We can <strong>handle Null values<\/strong> in the dataset with the mean (commonly known as imputation). This is a very common and easy practice. Not only this, but we can also calculate accuracy for regression algorithms. Don&#8217;t worry if you don&#8217;t know much about regression or if you don&#8217;t about null values, you will get a basic idea along the way.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-a-mean-squared-error\"><span class=\"ez-toc-section\" id=\"a_Mean_Squared_Error\"><\/span>a. Mean Squared Error<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In statistics, <a href=\"http:\/\/www.pythonpool.com\/mean-squared-error-python\/\" target=\"_blank\" rel=\"noopener\">mean squared<\/a> error or <strong>MSE is used to calculate the average of the squares of errors<\/strong>. In other words, it is taking the difference between the predicted and the actual value, then squaring it and taking the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Average\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">average<\/a> of all the values. Let us now see how we can do this using numpy mean.<\/p>\n\n\n\n<p>For example, suppose the actual price of a house is 100000,120115,400030, 500000. And we have created a model, which has predicted the value to be &#8211; 100400,121015,402090, 509070.<\/p>\n\n\n\n<p>Now, we can calculate the mean squared error.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nactual_values=&#x5B;100000,120115,400030, 500000]\npredicted_values=&#x5B;100400,121015,402090, 509070]\nsquared_difference=&#x5B;]\nfor values in range(len(actual_values)):\n    diff=actual_values&#x5B;values] - predicted_values&#x5B;values]\n    squared_difference.append(diff**2)\nprint(numpy.mean(squared_difference))\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-preformatted\">21869625.0<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b-filling-nan-values-using-numpy-mean\"><span class=\"ez-toc-section\" id=\"b_Filling_Nan_values_using_numpy_mean\"><\/span>b. Filling Nan values using numpy mean<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Suppose we have a dataset in which we have the age of a person. And there are some Nan (<a href=\"http:\/\/www.pythonpool.com\/python-null\/\" target=\"_blank\" aria-label=\"undefined (opens in a new tab)\" rel=\"noreferrer noopener\">null<\/a> values in that dataset). Let us see how we will fill those null values.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pandas as pd\nimport numpy\n# creating dataset\ndataset=pd.DataFrame(&#x5B;12,55,70,numpy.NaN,33,28,numpy.NaN,44,35,29],columns=&#x5B;&quot;Age&quot;])\nprint(dataset)\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"436\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23-1024x436.png\" alt=\"numpy mean\" class=\"wp-image-3773\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23-1024x436.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23-300x128.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23-768x327.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23-1536x655.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-23.png 1586w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># finding the mean of ages\nmean=numpy.mean(dataset)\nprint(mean)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Age 38.25 dtype: float64<\/pre>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# filling the null values with mean\ndataset=dataset.fillna(mean)\nprint(dataset)\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"437\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24-1024x437.png\" alt=\"numpy mean\" class=\"wp-image-3774\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24-1024x437.png 1024w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24-300x128.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24-768x328.png 768w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24-1536x656.png 1536w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/image-24.png 1584w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We can check that now there are no Nan values in our dataset.<\/p>\n\n\n\n<h2 class=\"has-vivid-red-color has-text-color wp-block-heading\" id=\"h-must-read\"><span class=\"ez-toc-section\" id=\"Must_Read\"><\/span>Must Read:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"http:\/\/www.pythonpool.com\/python-lowercase\/\">How to Convert String to Lowercase in<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/square-root-in-python\/\">How to Calculate Square Root<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-user-input\/\">User Input | Input () Function | Keyboard Input<\/a><\/li><li><a href=\"http:\/\/www.pythonpool.com\/python-book\/\">Best Book to Learn Python<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" 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>We have seen how important the numpy mean function is in programming. We can fill the <strong>null values in the dataset, calculate the accuracy of our model<\/strong>, and do so much more stuff. There are some other ways of calculating mean in python but numpy mean is quite fast and works for any <strong>dimensional arrays.<\/strong><\/p>\n\n\n\n<p>Try to run the programs on your side and let us know if you have any queries.<\/p>\n\n\n\n<p><strong><em>Happy Coding!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In statistics, three of the most important operations is to find the mean, median, and mode of the given data. Lots of insights can be &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Numpy Mean: Implementation and Importance\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/numpy-mean\/#more-3772\" aria-label=\"More on Numpy Mean: Implementation and Importance\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":3777,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1495],"tags":[1885,1874,1878,1872,1881,1886,1877,1882,1867,1865,1879,1875,1883,1870,1884,1873,1871,1868,1869,1876,1880,1866],"class_list":["post-3772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-numpy","tag-how-to-calculate-mean-of-numpy-array","tag-mean-in-numpy","tag-mean-numpy","tag-mean-of-numpy-array","tag-mean-square-error-numpy","tag-mean-squared-error-numpy","tag-numpy-array-mean","tag-numpy-average-vs-mean","tag-numpy-geometric-mean","tag-numpy-mean","tag-numpy-mean-absolute-error","tag-numpy-mean-and-std","tag-numpy-mean-axis","tag-numpy-mean-function","tag-numpy-mean-ignore-nan","tag-numpy-mean-nan","tag-numpy-mean-of-array","tag-numpy-mean-square-error","tag-numpy-rolling-mean","tag-numpy-root-mean-square","tag-numpy-weighted-mean","tag-python-numpy-mean","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Numpy Mean: Implementation and Importance - Python Pool<\/title>\n<meta name=\"description\" content=\"We can calculate the mean of an array using numpy mean. There are different parameters like axis, dtype, out which we change according to our needs.\" \/>\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-mean\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Numpy Mean: Implementation and Importance\" \/>\n<meta property=\"og:description\" content=\"In statistics, three of the most important operations is to find the mean, median, and mode of the given data. Lots of insights can be taken when these\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/numpy-mean\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-31T09:36:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T09:30:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"264\" \/>\n\t<meta property=\"og:image:height\" content=\"159\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashwini Mandani\" \/>\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=\"Ashwini Mandani\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/\"},\"author\":{\"name\":\"Ashwini Mandani\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\"},\"headline\":\"Numpy Mean: Implementation and Importance\",\"datePublished\":\"2020-07-31T09:36:10+00:00\",\"dateModified\":\"2021-06-14T09:30:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/\"},\"wordCount\":894,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png\",\"keywords\":[\"how to calculate mean of numpy array\",\"mean in numpy\",\"mean numpy\",\"mean of numpy array\",\"mean square error numpy\",\"mean squared error numpy\",\"numpy array mean\",\"numpy average vs mean\",\"numpy geometric mean\",\"numpy mean\",\"numpy mean absolute error\",\"numpy mean and std\",\"numpy mean axis\",\"numpy mean function\",\"numpy mean ignore nan\",\"numpy mean nan\",\"numpy mean of array\",\"numpy mean square error\",\"numpy rolling mean\",\"numpy root mean square\",\"numpy weighted mean\",\"python numpy mean\"],\"articleSection\":[\"Numpy\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-mean\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/\",\"url\":\"https:\/\/www.pythonpool.com\/numpy-mean\/\",\"name\":\"Numpy Mean: Implementation and Importance - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png\",\"datePublished\":\"2020-07-31T09:36:10+00:00\",\"dateModified\":\"2021-06-14T09:30:26+00:00\",\"description\":\"We can calculate the mean of an array using numpy mean. There are different parameters like axis, dtype, out which we change according to our needs.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-mean\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png\",\"width\":264,\"height\":159,\"caption\":\"numpy mean\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-mean\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Numpy Mean: Implementation and Importance\"}]},{\"@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\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/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\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056\",\"name\":\"Ashwini Mandani\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g\",\"caption\":\"Ashwini Mandani\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Numpy Mean: Implementation and Importance - Python Pool","description":"We can calculate the mean of an array using numpy mean. There are different parameters like axis, dtype, out which we change according to our needs.","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:\/\/www.pythonpool.com\/numpy-mean\/","og_locale":"en_US","og_type":"article","og_title":"Numpy Mean: Implementation and Importance","og_description":"In statistics, three of the most important operations is to find the mean, median, and mode of the given data. Lots of insights can be taken when these","og_url":"https:\/\/www.pythonpool.com\/numpy-mean\/","og_site_name":"Python Pool","article_published_time":"2020-07-31T09:36:10+00:00","article_modified_time":"2021-06-14T09:30:26+00:00","og_image":[{"width":264,"height":159,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png","type":"image\/png"}],"author":"Ashwini Mandani","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Ashwini Mandani","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/"},"author":{"name":"Ashwini Mandani","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056"},"headline":"Numpy Mean: Implementation and Importance","datePublished":"2020-07-31T09:36:10+00:00","dateModified":"2021-06-14T09:30:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/"},"wordCount":894,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png","keywords":["how to calculate mean of numpy array","mean in numpy","mean numpy","mean of numpy array","mean square error numpy","mean squared error numpy","numpy array mean","numpy average vs mean","numpy geometric mean","numpy mean","numpy mean absolute error","numpy mean and std","numpy mean axis","numpy mean function","numpy mean ignore nan","numpy mean nan","numpy mean of array","numpy mean square error","numpy rolling mean","numpy root mean square","numpy weighted mean","python numpy mean"],"articleSection":["Numpy"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/numpy-mean\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/numpy-mean\/","url":"https:\/\/www.pythonpool.com\/numpy-mean\/","name":"Numpy Mean: Implementation and Importance - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png","datePublished":"2020-07-31T09:36:10+00:00","dateModified":"2021-06-14T09:30:26+00:00","description":"We can calculate the mean of an array using numpy mean. There are different parameters like axis, dtype, out which we change according to our needs.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/numpy-mean\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/07\/Fibonacci-series-in-Python-1.png","width":264,"height":159,"caption":"numpy mean"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/numpy-mean\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Numpy Mean: Implementation and Importance"}]},{"@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":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/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\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/8a75fb48eb1f3dc952df65a8c28ac056","name":"Ashwini Mandani","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f765ed1940ac0ae1d30ce4cb2f1452c1e83143b07354d25a42c1cd118980e269?s=96&d=wavatar&r=g","caption":"Ashwini Mandani"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=3772"}],"version-history":[{"count":7,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3772\/revisions"}],"predecessor-version":[{"id":24427,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/3772\/revisions\/24427"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/3777"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=3772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=3772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=3772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}