

{"id":79325,"date":"2020-07-16T17:53:23","date_gmt":"2020-07-16T12:23:23","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=79325"},"modified":"2021-05-09T13:13:44","modified_gmt":"2021-05-09T07:43:44","slug":"numpy-array","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/numpy-array\/","title":{"rendered":"NumPy Array Tutorial &#8211; Python NumPy Array Operations and Methods"},"content":{"rendered":"<p>The most important feature of NumPy is the homogeneous high-performance n-dimensional array object. Data manipulation in Python is nearly equivalent to the manipulation of NumPy arrays.<\/p>\n<p>NumPy array manipulation is basically related to accessing data and sub-arrays. It also includes array splitting, reshaping, and joining of arrays. Even the other external libraries in Python relate to NumPy arrays.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79359\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg\" alt=\"NumPy Array\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h2>Numpy Array Basics<\/h2>\n<p>Arrays in NumPy are synonymous with lists in Python with a homogenous nature. The homogeneity helps to perform smoother mathematical operations.<\/p>\n<p>These arrays are mutable. NumPy is useful to perform basic operations like finding the dimensions, the bite-size, and also the data types of elements of the array.<\/p>\n<h2>NumPy Array Creation<\/h2>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79361\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF.jpg\" alt=\"Array Creation in NumPy\" width=\"574\" height=\"452\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF.jpg 574w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF-300x236.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF-150x118.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Creation-dF-520x409.jpg 520w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/a><\/h3>\n<h3>1. Using the NumPy functions<\/h3>\n<p>NumPy has a variety of built-in functions to create an array.<\/p>\n<h4>a. Creating one-dimensional array in NumPy<\/h4>\n<p>For 1-D arrays the most common function is np.arange(..), passing any value create an array from 0 to that number.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import numpy as np\r\n           array=np.arange(20)\r\n           array\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12, 13, 14, 15, 16, 17, 18, 19])<\/div>\n<p>We can check the dimensions by using <strong>array.shape.<\/strong><\/p>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">(20,)<\/div>\n<p>To access the element of the array we can specify its non-negative index.<br \/>\n<strong>array[3]<\/strong><\/p>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">3<\/div>\n<h4>b. Creating two-dimensional arrays in NumPy<\/h4>\n<p>We can use reshape()function along with the arange() function to create a 2D array. The reshape()function specifies the rows and columns.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array=np.arange(20).reshape(4,5)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([[ 0, 1, 2, 3, 4],<br \/>\n[ 5, 6, 7, 8, 9],<br \/>\n[10, 11, 12, 13, 14]<br \/>\n[15, 16, 17, 18, 19]])<\/div>\n<p>In 2-D arrays to access the elements, we will require to specify two values for row and column respectively.<\/p>\n<p>Similarly, we can create 3-D and more by increasing the number of parameters in the reshape()function.<\/p>\n<h4>c. Using other NumPy functions<\/h4>\n<p>We can use other functions like and to quickly create filled arrays.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">np.zeros((2,4))\r\n            np.ones((3,6))<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([[0., 0., 0., 0.],<br \/>\n[0., 0., 0., 0.]])array([[1., 1., 1., 1., 1., 1.],<br \/>\n[1., 1., 1., 1., 1., 1.],<br \/>\n[1., 1., 1., 1., 1., 1.]])<\/div>\n<p>The .empty() function creates an array with random variables and the full() function creates an n*n array with the given value.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">np.empty((2,3))\r\n      np.full((2,2), 3)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([[2.69893675e-316, 0.00000000e+000, 0.00000000e+000],<br \/>\n[0.00000000e+000, 0.00000000e+000, 0.00000000e+000]])<br \/>\narray([[3, 3],<br \/>\n[3, 3]])<\/div>\n<p>The .eye( , )function creates an array with diagonals as 1 and other<br \/>\nvalues as 0. The .linspace(, ,)<br \/>\nfunction outputs an equally spaced array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">np.eye(3,3)\r\n     np.linspace(0, 10, num=4)<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([[1., 0., 0.],<br \/>\n[0., 1., 0.],<br \/>\n[0., 0., 1.]])<br \/>\narray([ 0. , 3.33333333, 6.66666667, 10. ])<\/div>\n<table style=\"height: 1460px\" width=\"789\">\n<tbody>\n<tr>\n<td><strong>Sr No.<\/strong><\/td>\n<td><strong>Function<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">1<\/span><\/td>\n<td><span style=\"font-weight: 400\">empty_like()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return a new array with the same shape and type\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<td><span style=\"font-weight: 400\">ones_like()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return an array of ones with the same shape and type.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">3<\/span><\/td>\n<td><span style=\"font-weight: 400\">zeros_like()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return an array of zeros with the same shape and type\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">4<\/span><\/td>\n<td><span style=\"font-weight: 400\">full_like()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return a full array with the same shape and type\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">5<\/span><\/td>\n<td><span style=\"font-weight: 400\">asarray()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Convert the input to an array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">6<\/span><\/td>\n<td><span style=\"font-weight: 400\">geomspace()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return evenly spaced numbers on a log scale.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">7<\/span><\/td>\n<td><span style=\"font-weight: 400\">copy()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a copy of the given object<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">8<\/span><\/td>\n<td><span style=\"font-weight: 400\">diag()<\/span><\/td>\n<td><span style=\"font-weight: 400\"> a diagonal array<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">9<\/span><\/td>\n<td><span style=\"font-weight: 400\">frombuffer()<\/span><\/td>\n<td><span style=\"font-weight: 400\"> buffer as a 1-D array<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">10<\/span><\/td>\n<td><span style=\"font-weight: 400\">fromfile()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Construct an array from text or binary file<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">11<\/span><\/td>\n<td><span style=\"font-weight: 400\">bmat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Build a matrix object from a string, nested sequence, or array<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">12<\/span><\/td>\n<td><span style=\"font-weight: 400\">mat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Interpret the input as a matrix<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">13<\/span><\/td>\n<td><span style=\"font-weight: 400\">vander()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Generate a Vandermonde matrix<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">14<\/span><\/td>\n<td><span style=\"font-weight: 400\">triu()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Upper triangle of array<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">15<\/span><\/td>\n<td><span style=\"font-weight: 400\">tril()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Lower triangle of array<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">16<\/span><\/td>\n<td><span style=\"font-weight: 400\">tri()<\/span><\/td>\n<td><span style=\"font-weight: 400\">An array with ones at &amp; below the given diagonal and zeros elsewhere<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">17<\/span><\/td>\n<td><span style=\"font-weight: 400\">diagflat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">two-dimensional array with the flattened input as a diagonal<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">18<\/span><\/td>\n<td><span style=\"font-weight: 400\">fromfunction()<\/span><\/td>\n<td><span style=\"font-weight: 400\">executing a function over each coordinate<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">19<\/span><\/td>\n<td><span style=\"font-weight: 400\">logspace()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return numbers spaced evenly on a log scale<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">20<\/span><\/td>\n<td><span style=\"font-weight: 400\">meshgrid()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Return coordinate matrices from coordinate vectors<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. Conversion from Python structure like lists<\/h3>\n<p>We can use the Python lists to create arrays by passing a list to the array function. We can also directly create an array of elements by passing a list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">array=np.array([4,5,6])\r\n            array\r\n                      \r\n                        list=[4,5,6]\r\n            list\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>array([4, 5, 6])[4, 5, 6]<\/p>\n<\/div>\n<p>To create 2-D or more we pass a sequence of lists.<\/p>\n<h3>3. Using other library functions<\/h3>\n<p>We can use the function to create an array with random values between 0 and 1. This is a useful case in scenarios with random nature.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">np.random.random((2,3))<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">array([[0.42593659, 0.91495384, 0.05727104],<br \/>\n[0.3754818 , 0.63166016, 0.5901392 ]])<\/div>\n<h2>NumPy Array Indexing<\/h2>\n<p>Indexing of the array has to be proper in order to access and manipulate its values. Indexing can be done through:<\/p>\n<ul>\n<li><strong>Slicing<\/strong> \u2013 we perform slicing on NumPy arrays with the declaration of a slice for all the dimensions.<\/li>\n<li><strong>Integer array Indexing<\/strong>&#8211; users can pass lists for one to one mapping of corresponding elements for each dimension.<\/li>\n<li><strong>Boolean Array Indexing<\/strong>&#8211; we can pick elements after satisfying a particular Boolean condition.<\/li>\n<\/ul>\n<h2>NumPy Basic Array Operations<\/h2>\n<p>There is a vast range of built-in operations that we can perform on these arrays.<\/p>\n<p><strong>1. ndim<\/strong> &#8211; It returns the dimensions of the array.<br \/>\n<strong>2. itemsize<\/strong> \u2013 It calculates the byte size of each element.<br \/>\n<strong>3. dtype<\/strong> &#8211; It can determine the data type of the element.<br \/>\n<strong>4. reshape<\/strong> &#8211; It provides a new view.<br \/>\n<strong>5. slicing<\/strong> &#8211; It extracts a particular set of elements.<br \/>\n<strong>6. linspace<\/strong> &#8211; Returns evenly spaced elements.<br \/>\n<strong>7.<\/strong> max\/min , sum, sqrt<br \/>\n<strong>8. ravel<\/strong> &#8211; It converts the array into a single line.<\/p>\n<p>There are also a few Special Operations like sine, cosine, tan, log, etc.<\/p>\n<h2>Checking Array Dimensions in NumPy<\/h2>\n<p>We can determine the NumPy array dimensions using the ndim attribute. The argument return an integer that indicates the array dimension.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import numpy as np\r\n\r\na = np.array(10)\r\nb = np.array([1,1,1,1])\r\nc = np.array([[1, 1, 1], [2,2,2]])\r\nd = np.array([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]])\r\n\r\nprint(a.ndim)\r\nprint(b.ndim)\r\nprint(c.ndim)\r\nprint(d.ndim)\r\n\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">0 1 2 3<\/div>\n<h2>Higher Dimensional Arrays in NumPy<\/h2>\n<p>In Numpy we can have arrays with any number of dimensions. There can be arrays with a high number of dimensions. We define the number of dimensions with the ndim argument.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import numpy as np\r\n\r\narr = np.array([1, 1, 1, 1, 1], ndmin=10)\r\n\r\nprint(arr)\r\nprint('number of dimensions :', arr.ndim)\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">[[[[[[[[[[1 1 1 1 1]]]]]]]]]] number of dimensions : 10<\/div>\n<p>In the above example, the innermost dimension (10th dim) has 5 elements, the 9th dim has 1 element that is the vector, the 8th dim has 1 element that is the matrix with the vector, the 7th dim has 1 element that is 3D array 6th dim has 1 element that is a 4D array and so on.<\/p>\n<h2>Indexing and Slicing in NumPy<\/h2>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79360\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing.jpg\" alt=\"NumPy Array Indexing\" width=\"726\" height=\"333\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing.jpg 726w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing-300x138.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing-150x69.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Array-Indexing-520x239.jpg 520w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><\/a><\/p>\n<p>These are two very important concepts. It is useful when we want to work with sub-arrays.<br \/>\nIndexing starts with zero as the first index. We can retrieve element values by its index value. For 2 or more dimensional arrays, we have to specify 2 or more indices. Indexing can be of two types<\/p>\n<h3>1. Integer array indexing<\/h3>\n<p>We pass lists for indexing in all the dimensions. Then one to one mapping occurs for the creation of a new array.<\/p>\n<h3>2. Boolean array indexing<\/h3>\n<p>In this type of indexing, we carry out a condition check. If the boolean condition satisfies we create an array of those elements.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import numpy as np\r\narr=([1,2,5,6,7])\r\narr[3]\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">6<\/div>\n<p><strong>Slicing<\/strong> is similar to indexing, but it retrieves a string of values. The range is defined by the starting and ending indices. It is similar to lists in Python. The arrays can also be sliced. The arrays can be single or multidimensional. We can specify slices for all the dimensions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import numpy as np\r\narr=([1,2,5,6,7])\r\narr[2:5]\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">[5, 6, 7]<\/div>\n<h2>Advanced Methods on Arrays in NumPy<\/h2>\n<p>A few advanced methods available for NumPy Arrays are -:<\/p>\n<p><strong>1. Staking (along different axes)<\/strong> &#8211; Horizontally, Vertically, as columns and we can also perform concatenation along a specific axis.<br \/>\n<strong>2. Splitting<\/strong> &#8211; Array can be split along horizontal, vertical, or along a specific axis.<br \/>\n<strong>3. Broadcasting<\/strong> \u2013 with this method we can convert arrays to have compatible shapes to perform arithmetic operations. In order to broadcast the trailing axes should be either the same or one of them should be one.<br \/>\n<strong>4. DateTime<\/strong> &#8211; NumPy has its own DateTime data type like python\u2019s inbuilt named datetime64.<br \/>\n<strong>5. Linear algebra<\/strong> &#8211; we can perform linear algebra on arrays using this module.<\/p>\n<h2>Summary<\/h2>\n<p>A vast range of operations is available for NumPy array manipulation. We can start operating with arrays using these basic tools of array creation, indexing, etc.<\/p>\n<p>Creating and populating the array with elements is the most basic function. Above is more of a brief introduction to the available function and methods on arrays.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The most important feature of NumPy is the homogeneous high-performance n-dimensional array object. Data manipulation in Python is nearly equivalent to the manipulation of NumPy arrays. NumPy array manipulation is basically related to accessing&#46;&#46;&#46;<\/p>\n","protected":false},"author":6,"featured_media":79359,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22401],"tags":[22636,22635,22637],"class_list":["post-79325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-numpy","tag-array-in-numpy","tag-numpy-array","tag-python-numpy-array"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>NumPy Array Tutorial - Python NumPy Array Operations and Methods - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about NumPy Array, NumPy Array creation, various array functions, array indexing &amp; Slicing, array operations, methods and dimensions,\" \/>\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\/numpy-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NumPy Array Tutorial - Python NumPy Array Operations and Methods - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about NumPy Array, NumPy Array creation, various array functions, array indexing &amp; Slicing, array operations, methods and dimensions,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/numpy-array\/\" \/>\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=\"2020-07-16T12:23:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-09T07:43:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.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=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"NumPy Array Tutorial - Python NumPy Array Operations and Methods - DataFlair","description":"Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,","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\/numpy-array\/","og_locale":"en_US","og_type":"article","og_title":"NumPy Array Tutorial - Python NumPy Array Operations and Methods - DataFlair","og_description":"Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,","og_url":"https:\/\/data-flair.training\/blogs\/numpy-array\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2020-07-16T12:23:23+00:00","article_modified_time":"2021-05-09T07:43:44+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/2c58ecb4f73a39f0ef993f1ddfcd7b89"},"headline":"NumPy Array Tutorial &#8211; Python NumPy Array Operations and Methods","datePublished":"2020-07-16T12:23:23+00:00","dateModified":"2021-05-09T07:43:44+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/"},"wordCount":1203,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg","keywords":["array in numpy","numpy array","python numpy array"],"articleSection":["NumPy Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/numpy-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/","url":"https:\/\/data-flair.training\/blogs\/numpy-array\/","name":"NumPy Array Tutorial - Python NumPy Array Operations and Methods - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg","datePublished":"2020-07-16T12:23:23+00:00","dateModified":"2021-05-09T07:43:44+00:00","description":"Learn about NumPy Array, NumPy Array creation, various array functions, array indexing & Slicing, array operations, methods and dimensions,","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/numpy-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2020\/07\/Arrays-in-NumPy-df.jpg","width":1200,"height":628,"caption":"NumPy Array"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/numpy-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"NumPy Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/numpy\/"},{"@type":"ListItem","position":3,"name":"NumPy Array Tutorial &#8211; Python NumPy Array Operations and Methods"}]},{"@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\/2c58ecb4f73a39f0ef993f1ddfcd7b89","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ce4a0e3e542444fc73bbebf83e89e8b73e2d95ccb1fcee64da9945f078b97c5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"The DataFlair Team provides industry-driven content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our expert educators focus on delivering value-packed, easy-to-follow resources for tech enthusiasts and professionals.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam2\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79325","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\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=79325"}],"version-history":[{"count":4,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79325\/revisions"}],"predecessor-version":[{"id":93079,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/79325\/revisions\/93079"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/79359"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=79325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=79325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=79325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}