

{"id":22004,"date":"2018-07-20T03:35:15","date_gmt":"2018-07-19T22:05:15","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=22004"},"modified":"2026-04-27T15:15:07","modified_gmt":"2026-04-27T09:45:07","slug":"python-numpy-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/","title":{"rendered":"Python NumPy Tutorial  &#8211; NumPy ndarray &amp; NumPy Array"},"content":{"rendered":"<p>In our last Python Library tutorial, we studied Python SciPy. Now we are going to study Python NumPy.<\/p>\n<p>In this NumPy tutorial, we are going to discuss the features, installation, and NumPy ndarray. Moreover, we will cover the data types and arrays in NumPy. So, let\u2019s begin the Python NumPy Tutorial.<\/p>\n<div id=\"attachment_22035\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22035\" class=\"wp-image-22035 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg\" alt=\"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-22035\" class=\"wp-caption-text\">Python NumPy Tutorial &#8211; NumPy ndarray &amp; NumPy Array<\/p><\/div>\n<h3 class=\"western\">What is NumPy?<\/h3>\n<p>A library for Python, NumPy, lets you work with huge, multidimensional matrices and arrays. Along with that, it provides a set of high-level functions to perform mathematical operations on these structures.<\/p>\n<p><strong>Here is a brief about it:<\/strong><\/p>\n<ul>\n<li><strong>Author-<\/strong> Travis Oliphant<\/li>\n<li><strong>First Release-<\/strong> 1995 (Released as Numeric; Changed to NumPy in 2006)<\/li>\n<li><strong>Stable Release-<\/strong> June, 2018<\/li>\n<li><strong>Written in <\/strong>Python Programming, C<\/li>\n<\/ul>\n<p>Python NumPy is cross-platform and BSD-licensed. We often use it with packages like Matplotlib and SciPy.<\/p>\n<p>This can be seen as an alternative to MATLAB. The term \u2018<em>Numpy<\/em>\u2019 is a portmanteau of the words \u2018NUM<em>erical<\/em>\u2019 and \u2018PY<em>thon<\/em>\u2019.<\/p>\n<h3 class=\"western\">Features of Numpy in Python<\/h3>\n<p><strong>In this Python NumPy Tutorial, we are going to study the features of NumPy:<\/strong><\/p>\n<ul>\n<li><em>NumPy<\/em> stands on CPython, a non-optimizing bytecode interpreter.<\/li>\n<li>Multidimensional arrays.<\/li>\n<li>Functions and operators for these arrays.<\/li>\n<li>Python Alternative to MATLAB.<\/li>\n<li>ndarray- n-dimensional arrays.<\/li>\n<li>Fourier transforms and shape manipulation.<\/li>\n<li>Linear algebra and random number generation.<\/li>\n<\/ul>\n<h3 class=\"western\">How to Install NumPy?<\/h3>\n<p>You can use pip to install numpy-<\/p>\n<pre class=\"EnlighterJSRAW\">pip install numpy\r\n<\/pre>\n<p>Then you can import it as-<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import numpy as np\r\n<\/pre>\n<h3>Python NumPy ndarray<\/h3>\n<p>This is one of the most important <em>features of numpy<\/em>. ndarray is an <em>n-dimensional array<\/em>, a grid of values of the same kind. A tuple of nonnegative integers indexes this tuple. An array\u2019s rank is its number of dimensions.<\/p>\n<p>Let\u2019s take a few examples.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([1,2,3])\r\n&gt;&gt;&gt; type(a)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">\n<p>&lt;class &#8216;numpy.ndarray&#8217;&gt;<\/p>\n<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a.shape<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">(3,)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[0],a[2]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">(1, 3)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[1]=5\r\n&gt;&gt;&gt; a<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([1, 5, 3])<\/div>\n<p>As you can see, the array\u2019s shape is (3,). What happens when we build an array of more than one dimension?<\/p>\n<p>Let\u2019s see.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; b=np.array([[2,7,9],[5,1,3]])\r\n&gt;&gt;&gt; b<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[2, 7, 9],<br \/>\n[5, 1, 3]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; b[0,1]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">7<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; b.shape<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">(2, 3)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; b.size\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">6<\/div>\n<h4>1. How to Create a NumPy Array?<\/h4>\n<p>The following lines of code create a few more arrays:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.arange(7) #This is like range in Python<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([0, 1, 2, 3, 4, 5, 6])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.random.random((3,3)) #Fills in random values<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[0.56074267, 0.67303599, 0.65973007],<br \/>\n[0.37222497, 0.13230271, 0.40858618],<br \/>\n[0.74455771, 0.52119999, 0.6927821 ]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.ones((2,3))\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1., 1., 1.],<br \/>\n[1., 1., 1.]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.zeros((1,2))\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[0., 0.]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.eye(3) #Identity matrix\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1., 0., 0.],<br \/>\n[0., 1., 0.],<br \/>\n[0., 0., 1.]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.full((3,2),7) #Matrix of constants\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[7, 7],<br \/>\n[7, 7],<br \/>\n[7, 7]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.linspace(1,2,4) #4 values spaced evenly between, and including, 1 and 2.\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([1. , 1.33333333, 1.66666667, 2. ])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.empty([2,3]) #Empty array\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1., 0., 3.],<br \/>\n[0., 4., 0.]])<\/div>\n<h4 class=\"western\">2. Some Parameters<\/h4>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.array([1,3,4],ndmin=3) #Minimum dimension\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[[1, 3, 4]]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.array([1,3,4],dtype=complex) #Data type<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([1.+0.j, 3.+0.j, 4.+0.j])<\/div>\n<h3 class=\"western\">Data Types in Numpy<\/h3>\n<p>As we\u2019ve said before, a NumPy array holds elements of the same kind. If, while creating a NumPy array, you do not specify the data type, NumPy will decide it for you.<\/p>\n<p><strong>We have the following data types:<\/strong><\/p>\n<p>bool_, int_, intc, intp, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float_, float16, float32, float64, complex_, complex64, complex128<\/p>\n<p>We can confirm:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.dtype(np.int32)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">dtype(&#8216;int32&#8217;)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.dtype('i4')\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">dtype(&#8216;int32&#8217;)<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.dtype('i8')\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">dtype(&#8216;int64&#8217;)<\/div>\n<h3 class=\"western\">Functions of NumPy Array<\/h3>\n<p>Let\u2019s take a look at all that we can do to an array and what more we can find out about it.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2,3],[4,5,6]])\r\n&gt;&gt;&gt; a.reshape(3,2)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1, 2],<br \/>\n[3, 4],<br \/>\n[5, 6]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a.ndim #Number of array dimensions\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">2<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.array([[1,2,3],[4,5,6]]).itemsize #Length of each element in bytes\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">4<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.array([[1,2,3],[4,5,6]],dtype=np.int8).itemsize\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">1<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1, 2, 3],<br \/>\n[4, 5, 6]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a.flags\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">C_CONTIGUOUS: True<br \/>\nF_CONTIGUOUS: False<br \/>\nOWNDATA: True<br \/>\nWRITEABLE: True<br \/>\nALIGNED: True<br \/>\nWRITEBACKIFCOPY: False<br \/>\nUPDATEIFCOPY: False<\/div>\n<h3 class=\"western\">Numpy Array Indexing in Python<\/h3>\n<p>It is possible to slice your NumPy arrays- with multiple slices for multidimensional arrays.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2,3],[4,5,6],[7,8,9]])\r\n&gt;&gt;&gt; b=a[:2,1:3]\r\n&gt;&gt;&gt; b<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[2, 3],<br \/>\n[5, 6]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[1,2]\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">6<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; b[0,0]=79\r\n&gt;&gt;&gt; a<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[ 1, 79, 3],<br \/>\n[ 4, 5, 6],<br \/>\n[ 7, 8, 9]])<\/div>\n<p>As you can see, changes to a slice modify an original.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[1,:]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([4, 5, 6])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[1:2,:]\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[4, 5, 6]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[:,1]\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([79, 5, 8])<\/div>\n<div id=\"attachment_22037\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-22037\" class=\"wp-image-22037 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01.jpg\" alt=\"Python NumPy Tutorial - NumPy Array Index\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Array-Indexing-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-22037\" class=\"wp-caption-text\">Python NumPy Tutorial &#8211; NumPy Array Index<\/p><\/div>\n<h4 class=\"western\">1. Integer Indexing in Python NumPy<\/h4>\n<p>It is possible to create an array from another.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2],[3,4],[5,6]])\r\n&gt;&gt;&gt; a[[0,1,2],[0,1,0]] #Prints elements at [0,0], [1,1], and [2,0]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([1, 4, 5])<\/div>\n<p>Let\u2019s pick elements-<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a = np.array([[1,2,3], [4,5,6], [7,8,9], [10, 11, 12]])\r\n&gt;&gt;&gt; b = np.array([0, 2, 0, 1])\r\n&gt;&gt;&gt; b<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([0, 2, 0, 1])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[np.arange(4), b]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([ 1, 6, 7, 11])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[np.arange(4), b]+=10\r\n&gt;&gt;&gt; a<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[11, 2, 3],<br \/>\n[ 4, 5, 16],<br \/>\n[17, 8, 9],<br \/>\n[10, 21, 12]])<\/div>\n<h4 class=\"western\">2. Boolean Indexing in Python NumPy<\/h4>\n<p>This will let you pick elements that satisfy a condition.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2],[3,4],[5,6]])\r\n&gt;&gt;&gt; boolean=(a&gt;3)\r\n&gt;&gt;&gt; boolean<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[False, False],<br \/>\n[False, True],<br \/>\n[ True, True]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a[boolean]<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([4, 5, 6])<\/div>\n<h3 class=\"western\">Mathematical Functions on Arrays in NumPy<\/h3>\n<p>Let\u2019s now look at some mathematical functions to call on arrays.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2,3],[4,5,6]])\r\n&gt;&gt;&gt; b=np.array([[7,8,9],[10,11,12]])\r\n&gt;&gt;&gt; np.add(a,b) #a+b does the same<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[ 8, 10, 12],<br \/>\n[14, 16, 18]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.subtract(a,b) #Same as a-b\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[-6, -6, -6],<br \/>\n[-6, -6, -6]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.multiply(a,b) #a*b works too\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[ 7, 16, 27],<br \/>\n[40, 55, 72]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.divide(a,b) #Same as a\/b\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[0.14285714, 0.25 , 0.33333333],<br \/>\n[0.4 , 0.45454545, 0.5 ]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.sqrt(a) #Produces square root\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1. , 1.41421356, 1.73205081],<br \/>\n[2. , 2.23606798, 2.44948974]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a=np.array([[1,2],[3,4]])\r\n&gt;&gt;&gt; np.sum(a)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">10<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.sum(a,axis=0) #Sum of each column\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([4, 6])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.sum(a,axis=1) #Sum of each row\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([3, 7])<\/div>\n<p>To transpose this matrix:<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; a.T\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[1, 3],<br \/>\n[2, 4]])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; np.array([1,3,2]).T #NOP\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([1, 3, 2])<\/div>\n<p>Some functions that operate on a larger context-<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; x=np.array([[1,2],[3,4]])\r\n&gt;&gt;&gt; y=np.array([[5,6],[7,8]])\r\n&gt;&gt;&gt; v=np.array([9,10])\r\n&gt;&gt;&gt; w=np.array([11,12])\r\n&gt;&gt;&gt; v.dot(w) #Same as np.dot(v,w)<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">219<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; x.dot(v)\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([29, 67])<\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; x.dot(y)\r\n<\/pre>\n<p><b>Output<\/b><\/p>\n<div class=\"code-output\">array([[19, 22],<br \/>\n[43, 50]])<\/div>\n<p>So, this was all about Python NumPy Tutorial. Hope you like our explanation.<\/p>\n<h3>Python Interview Questions on NumPy<\/h3>\n<ol>\n<li>What is a Python NumPy array?<\/li>\n<li>What is the purpose of NumPy in Python?<\/li>\n<li>What is the difference between Pandas and NumPy in Python?<\/li>\n<li>How does NumPy work in Python?<\/li>\n<li>What functions does NumPy provide in Python?<\/li>\n<\/ol>\n<h3 class=\"western\">Conclusion<\/h3>\n<p>That\u2019s the beauty of NumPy that it has turned Python into a powerhouse for numerics and data. Instead of counting things one by one, you can now handle huge amounts of information at once with incredible speed.<\/p>\n<p>Hence, in this Python NumPy Tutorial, we studied how to install NumPy and the NumPy ndarray.<\/p>\n<p>In addition, we discussed NumPy Array with its Functions and data types. This sums it up for NumPy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our last Python Library tutorial, we studied Python SciPy. Now we are going to study Python NumPy. In this NumPy tutorial, we are going to discuss the features, installation, and NumPy ndarray. Moreover,&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":22035,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[3491,4615,4982,6084,6218,7077,9171,9172,10728,15869],"class_list":["post-22004","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-data-types-in-numpy","tag-features-of-numpy","tag-functions-of-numpy-array","tag-how-to-create-numpy-array","tag-how-to-install-numpy","tag-introduction-to-numpy","tag-numpy-array-indexing","tag-numpy-data-types","tag-python-numpy-tutorial","tag-what-is-python-numpy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array - DataFlair<\/title>\n<meta name=\"description\" content=\"NumPy is a Python Library that lets you work with huge, multidimensional matrices and arrays. Let&#039;s discuss its Functions and data types.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array - DataFlair\" \/>\n<meta property=\"og:description\" content=\"NumPy is a Python Library that lets you work with huge, multidimensional matrices and arrays. Let&#039;s discuss its Functions and data types.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-19T22:05:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-27T09:45:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array - DataFlair","description":"NumPy is a Python Library that lets you work with huge, multidimensional matrices and arrays. Let's discuss its Functions and data types.","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:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array - DataFlair","og_description":"NumPy is a Python Library that lets you work with huge, multidimensional matrices and arrays. Let's discuss its Functions and data types.","og_url":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-07-19T22:05:15+00:00","article_modified_time":"2026-04-27T09:45:07+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python NumPy Tutorial &#8211; NumPy ndarray &amp; NumPy Array","datePublished":"2018-07-19T22:05:15+00:00","dateModified":"2026-04-27T09:45:07+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/"},"wordCount":792,"commentCount":7,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg","keywords":["Data Types in NumPy","Features of NumPy","Functions of NumPy Array","How to create NumPy Array","How to Install NumPy","Introduction to NumPy","Numpy Array Indexing","Numpy Data Types","Python NumPy Tutorial","What is Python NumPy"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/","name":"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg","datePublished":"2018-07-19T22:05:15+00:00","dateModified":"2026-04-27T09:45:07+00:00","description":"NumPy is a Python Library that lets you work with huge, multidimensional matrices and arrays. Let's discuss its Functions and data types.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/NumPy-Tutorial-01.jpg","width":1200,"height":628,"caption":"Python NumPy Tutorial - NumPy ndarray &amp; NumPy Array"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-numpy-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python NumPy Tutorial &#8211; NumPy ndarray &amp; NumPy Array"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22004","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=22004"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22004\/revisions"}],"predecessor-version":[{"id":147930,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/22004\/revisions\/147930"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/22035"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=22004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=22004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=22004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}