{"id":6178,"date":"2020-12-15T12:34:15","date_gmt":"2020-12-15T07:04:15","guid":{"rendered":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/?p=6178"},"modified":"2021-07-09T21:20:36","modified_gmt":"2021-07-09T15:50:36","slug":"numpy-diff","status":"publish","type":"post","link":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/","title":{"rendered":"What Is Numpy Diff? Along With Examples"},"content":{"rendered":"\n<p>Hello geeks and welcome to today&#8217;s article, we will discuss NumPy diff. Along with it, we will cover its syntax, different parameters, and also look at a couple of examples. But at first, let us try to understand it in general terms. Numpy is a mathematical module of python which provides a function called diff.<\/p>\n\n\n\n<p><strong>We can calculate the nth order discrete difference along with the given axis using Numpy Diff. The first-order difference is calculated by out[i]=arr[i+1]-arr[i]. To calculate the higher-order difference, we use the diff in a loop. Now we will look at its syntax followed by its parameters and then examples.<\/strong><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 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 \" >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-diff\/#Syntax_Of_Numpy_Diff\" title=\"Syntax Of Numpy Diff\">Syntax Of Numpy Diff<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#Parameters_Of_Numpy_Diff\" title=\"Parameters Of Numpy Diff\">Parameters Of Numpy Diff<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#Examples_Of_Numpy_Diff\" title=\"Examples Of Numpy Diff\">Examples Of Numpy Diff<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#What_is_Difference_between_Numpy_Diff_and_Gradient\" title=\"What is Difference between Numpy Diff and Gradient?\">What is Difference between Numpy Diff and Gradient?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#Must_Read\" title=\"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-6\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#One_More_Example_NUMPY_DIFF\" title=\"One More Example NUMPY DIFF\">One More Example NUMPY DIFF<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#CONCLUSION\" title=\"CONCLUSION\">CONCLUSION<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-syntax-of-numpy-diff\"><span class=\"ez-toc-section\" id=\"Syntax_Of_Numpy_Diff\"><\/span>Syntax Of Numpy Diff<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Given below is the general syntax of  NumPy diff<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>numpy.diff<\/code><strong>(<\/strong><em>a<\/em><strong>,&nbsp;<\/strong><em>n=1<\/em><strong>,&nbsp;<\/strong><em>axis=-1<\/em><strong>,&nbsp;<\/strong><em>prepend=&lt;no value&gt;<\/em><strong>,&nbsp;<\/strong><em>append=&lt;no value&gt;<\/em><strong>)<\/strong><\/pre>\n\n\n\n<p>Here we can see that the syntax has several parameters, some optional and some not. In the next section, we will cover the parameters in-depth and look at each parameter&#8217;s importance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-parameters-of-numpy-diff\"><span class=\"ez-toc-section\" id=\"Parameters_Of_Numpy_Diff\"><\/span>Parameters Of Numpy Diff<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"h-as-quiet-clear-from-the-syntax-there-are-total-5-parameters-associated-with-the\">As quite clear from the syntax there is a total of 5 parameters associated with it. We will cover each one in detail here<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-a-array_like\">a : array_like<\/h3>\n\n\n\n<p>It represents the input array and is a mandatory parameter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-n-int\">n : int<\/h3>\n\n\n\n<p>An optional parameter responsible for the number of times values is differenced. If no value is provided, it assumes the value to be 0, and the output is the same as the input.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-axis-int\">axis : int<\/h3>\n\n\n\n<p>The axis along which the difference is to be taken. By default, it is assumed as the last axis.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-prepend-append-array_like\">Prepend, Append: array_like<\/h3>\n\n\n\n<p>An optional parameter, responsible for the values to be append or prepend &#8220;<strong>A&#8221;<\/strong> long an axis before performing differences. Scalar values are expanded to arrays with length 1 in the direction of the axis. Otherwise, the shape and dimension must match &#8220;A&#8221; except along the x-axis.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-examples-of-numpy-diff\"><span class=\"ez-toc-section\" id=\"Examples_Of_Numpy_Diff\"><\/span>Examples Of Numpy Diff<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now lets us look at a couple of examples of NumPy diff<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as ppool\narr=ppool.arr(&#x5B;1,2,3,4,5])\nprint(&quot;Input array  : &quot;, arr) \nprint(&quot;First order difference  : &quot;, ppool.diff(arr, n=1)) \nprint(&quot;Second order difference : &quot;, ppool.diff(arr, n = 2)) \nprint(&quot;Third order difference  : &quot;, ppool.diff(arr, n = 3)) \n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Input array  :  &#91;1 2 3 4 5]\nFirst order difference  :  &#91;1 1 1 1]\nSecond order difference :  &#91;0 0 0]\nThird order difference  :  &#91;0 0]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation\">Explanation<\/h3>\n\n\n\n<p>In the above example, we can see the usage of  NumPy diff. Here we can see that we have defined an array. In the first step, we have not defined the value of n. So by default, it has assumed it to be =0 and returned the input <a href=\"https:\/\/en.wikipedia.org\/wiki\/Matrix_(mathematics)\" target=\"_blank\" rel=\"noreferrer noopener\">matrix<\/a>. For the second case, we  have defined n=1 so we get [1,1,1,1]. we can understand it as  initial matrix[1,2,3,4,5]-[0,1,2,3,4]=[1,1,1,1]. Similarly for the next step [1,1,1,1]-[0,1,1,1]=[0,0,0]. The process continues in a loop until we reach our desired number of n is achieved.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-difference-between-numpy-diff-and-gradient\"><span class=\"ez-toc-section\" id=\"What_is_Difference_between_Numpy_Diff_and_Gradient\"><\/span>What is Difference between Numpy Diff and Gradient?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Diff calculates the differences of matrix slices. This difference is calculated with a slice of dimension n. As a result, it returns the matrix of length smaller by n. Whereas, the gradient will produce an array of gradients with preserving the array length. So, if you want to numerical derivate of two arrays, you can use diff method provided you maintain the diff of the same length.<\/p>\n\n\n\n<h2 class=\"has-white-color has-vivid-green-cyan-background-color has-text-color has-background 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><li><a href=\"https:\/\/www.pythonpool.com\/python-help-function\/\" rel=\"noreferrer noopener\" target=\"_blank\">Python Help Function<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-max-int\/\" rel=\"noreferrer noopener\" target=\"_blank\">Python Max Int | What&#8217;s the Maximum Value of int Data Type<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/numpy-axis\/\" rel=\"noreferrer noopener\" target=\"_blank\">Numpy Axis in Python With Detailed Examples<\/a><\/li><li><a href=\"https:\/\/www.pythonpool.com\/python-int-to-binary\/\" rel=\"noreferrer noopener\" target=\"_blank\">Python int to Binary | Integer to Binary Conversion<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-one-more-example-numpy-diff\"><span class=\"ez-toc-section\" id=\"One_More_Example_NUMPY_DIFF\"><\/span>One More Example NUMPY DIFF<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport numpy as ppool  \n  \narr = ppool.array(&#x5B;&#x5B;1, 2, 3, 4], &#x5B;5, 6, 7, 8]]) \n   \nprint(&quot;Input array  : &quot;, arr) \nprint(&quot;Difference when axis is 0 : &quot;, ppool.diff(arr, axis = 0)) \nprint(&quot;Difference when axis is 1 : &quot;, ppool.diff(arr, axis = 1))\n<\/pre><\/div>\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Input array  :  &#91;&#91;1 2 3 4]\n &#91;5 6 7 8]]\nDifference when axis is 0 :  &#91;&#91;4 4 4 4]]\nDifference when axis is 1 :  &#91;&#91;1 1 1]\n &#91;1 1 1]]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-explanation-1\"><strong>Explanation<\/strong><\/h3>\n\n\n\n<p>In the above example, we see that instead of n, the operation is performed along the axis. We also know if the axis is not defined, it assumes the last axis for operating.<\/p>\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>In this article, we covered NumPy diff along with its syntax and parameters. Apart from that, we also looked at a couple of examples that involved operations based on different parameters. Finally, we can conclude that NumPy diff is used to calculate the nth discrete difference along the given curve. I hope that this article was able to clear your doubts. If you have any unsolved doubts, feel free to write them below in the comment section. You can also refer to other articles related to Numpy <a href=\"https:\/\/www.pythonpool.com\/numpy-hstack\/\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello geeks and welcome to today&#8217;s article, we will discuss NumPy diff. Along with it, we will cover its syntax, different parameters, and also look &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"What Is Numpy Diff? Along With Examples\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/numpy-diff\/#more-6178\" aria-label=\"More on What Is Numpy Diff? Along With Examples\">Read more<\/a><\/p>\n","protected":false},"author":11,"featured_media":6364,"comment_status":"open","ping_status":"closed","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":[2768,2763,2764,2766,2765,2767,2762],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v22.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What Is Numpy Diff? Along With Examples - Python Pool<\/title>\n<meta name=\"description\" content=\"We can calculate the nth order discrete difference along with the given axis using Numpy Diff. The first-order difference is calculated by...\" \/>\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-diff\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Is Numpy Diff? Along With Examples\" \/>\n<meta property=\"og:description\" content=\"Hello geeks and welcome to today&#039;s article, we will discuss NumPy diff. Along with it, we will cover its syntax, different parameters, and also look at a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/numpy-diff\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-15T07:04:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-09T15:50:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rohit Kumar\" \/>\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=\"Rohit Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/\"},\"author\":{\"name\":\"Rohit Kumar\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/664ced779ebbb8ddfd3c58a60d6f9d66\"},\"headline\":\"What Is Numpy Diff? Along With Examples\",\"datePublished\":\"2020-12-15T07:04:15+00:00\",\"dateModified\":\"2021-07-09T15:50:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/\"},\"wordCount\":646,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png\",\"keywords\":[\"diff functin in numpy\",\"diff two arrays numpy\",\"numpy .diff\",\"numpy diff array item\",\"numpy diff function\",\"numpy diff sequence\",\"python numpy diff\"],\"articleSection\":[\"Numpy\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-diff\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/\",\"url\":\"https:\/\/www.pythonpool.com\/numpy-diff\/\",\"name\":\"What Is Numpy Diff? Along With Examples - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png\",\"datePublished\":\"2020-12-15T07:04:15+00:00\",\"dateModified\":\"2021-07-09T15:50:36+00:00\",\"description\":\"We can calculate the nth order discrete difference along with the given axis using Numpy Diff. The first-order difference is calculated by...\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/numpy-diff\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png\",\"width\":1350,\"height\":650,\"caption\":\"numpy diff\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/numpy-diff\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What Is Numpy Diff? Along With Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"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\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/664ced779ebbb8ddfd3c58a60d6f9d66\",\"name\":\"Rohit Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/108d020b4b8cba046952e99dc32190f8?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/108d020b4b8cba046952e99dc32190f8?s=96&d=wavatar&r=g\",\"caption\":\"Rohit Kumar\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What Is Numpy Diff? Along With Examples - Python Pool","description":"We can calculate the nth order discrete difference along with the given axis using Numpy Diff. The first-order difference is calculated by...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/","og_locale":"en_US","og_type":"article","og_title":"What Is Numpy Diff? Along With Examples","og_description":"Hello geeks and welcome to today's article, we will discuss NumPy diff. Along with it, we will cover its syntax, different parameters, and also look at a","og_url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/","og_site_name":"Python Pool","article_published_time":"2020-12-15T07:04:15+00:00","article_modified_time":"2021-07-09T15:50:36+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png","type":"image\/png"}],"author":"Rohit Kumar","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Rohit Kumar","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#article","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/"},"author":{"name":"Rohit Kumar","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#\/schema\/person\/664ced779ebbb8ddfd3c58a60d6f9d66"},"headline":"What Is Numpy Diff? Along With Examples","datePublished":"2020-12-15T07:04:15+00:00","dateModified":"2021-07-09T15:50:36+00:00","mainEntityOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/"},"wordCount":646,"commentCount":0,"publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png","keywords":["diff functin in numpy","diff two arrays numpy","numpy .diff","numpy diff array item","numpy diff function","numpy diff sequence","python numpy diff"],"articleSection":["Numpy"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/","name":"What Is Numpy Diff? Along With Examples - Python Pool","isPartOf":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage"},"thumbnailUrl":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png","datePublished":"2020-12-15T07:04:15+00:00","dateModified":"2021-07-09T15:50:36+00:00","description":"We can calculate the nth order discrete difference along with the given axis using Numpy Diff. The first-order difference is calculated by...","breadcrumb":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#primaryimage","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-22.png","width":1350,"height":650,"caption":"numpy diff"},{"@type":"BreadcrumbList","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/numpy-diff\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"What Is Numpy Diff? Along With Examples"}]},{"@type":"WebSite","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#website","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/twitter.com\/pythonpool","https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#\/schema\/person\/664ced779ebbb8ddfd3c58a60d6f9d66","name":"Rohit Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/secure.gravatar.com\/avatar\/108d020b4b8cba046952e99dc32190f8?s=96&d=wavatar&r=g","contentUrl":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/secure.gravatar.com\/avatar\/108d020b4b8cba046952e99dc32190f8?s=96&d=wavatar&r=g","caption":"Rohit Kumar"}}]}},"_links":{"self":[{"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6178"}],"collection":[{"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=6178"}],"version-history":[{"count":16,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6178\/revisions"}],"predecessor-version":[{"id":14454,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6178\/revisions\/14454"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/6364"}],"wp:attachment":[{"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=6178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=6178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=6178"}],"curies":[{"name":"wp","href":"https:\/\/web.archive.org\/web\/20240926034930\/https:\/\/api.w.org\/{rel}","templated":true}]}}