{"id":88795,"date":"2023-12-07T18:00:35","date_gmt":"2023-12-07T12:30:35","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=88795"},"modified":"2023-12-07T18:00:35","modified_gmt":"2023-12-07T12:30:35","slug":"numpy-sorting-searching-and-counting","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/","title":{"rendered":"Numpy Sorting, Searching, and Counting"},"content":{"rendered":"<h2>Numpy\u2019s Sorting<\/h2>\n<p>Sorting involves arranging elements in a specific sequence based on certain criteria, such as numerical order (ascending or descending) or alphabetical order. NumPy&#8217;s sorting functions are optimized for large datasets and can be applied along specified axes in multi-dimensional arrays.<\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">FUNCTION<\/span><\/td>\n<td><span style=\"font-weight: 400\">DESCRIPTION<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.ndarray.sort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sorts an array in place.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.sort()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a copy of an array sorted along the first axis.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.sort_complex()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Sorts a complex array using the real part first, followed by the imaginary part.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.partition()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a partitioned copy of an array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.argpartition()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Performs an indirect partition along the given axis using the algorithm specified by the kind keyword.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>numpy.sort()<\/h3>\n<p>The numpy.sort() function organizes the elements of an array in ascending order along the specified axis.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import numpy as np\n\nDataFlair_array = np.array([5, 2, 8, 1, 3])\nsorted_array = np.sort(DataFlair_array)\n\nprint(\"Original Array:\", DataFlair_array)\nprint(\"Sorted Array:\", sorted_array)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Original Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Sorted Array:<\/strong> [1 2 3 5 8]<\/p>\n<h3>numpy.argsort()<\/h3>\n<p>The numpy.argsort() function returns the indices that would result in a sorted array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nindices = np.argsort(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices for Sorting:\", indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Indices for Sorting:<\/strong> [3 1 4 0 2]<\/p>\n<h3>numpy.lexsort()<\/h3>\n<p>The numpy.lexsort() function performs an indirect sort using a sequence of keys. It sorts multiple keys simultaneously.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">first_name = np.array(['John', 'Jane', 'Adam', 'Eve'])\nlast_name = np.array(['Doe', 'Smith', 'Smith', 'Doe'])\nindices = np.lexsort((last_name, first_name))\n\nprint(\"First Names:\", first_name)\nprint(\"Last Names:\", last_name)\nprint(\"Sorted Indices:\", indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>First Names:<\/strong> [&#8216;John&#8217; &#8216;Jane&#8217; &#8216;Adam&#8217; &#8216;Eve&#8217;]<br \/>\n<strong>Last Names:<\/strong> [&#8216;Doe&#8217; &#8216;Smith&#8217; &#8216;Smith&#8217; &#8216;Doe&#8217;]<br \/>\n<strong>Sorted Indices:<\/strong> [2 3 1 0]<\/p>\n<h3>numpy.ndarray.sort()<\/h3>\n<p>The sort() method of NumPy arrays performs an in-place sort.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nDataFlair_array.sort()\n\nprint(\"Sorted Array:\", DataFlair_array)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Sorted Array:<\/strong> [1 2 3 5 8]<\/p>\n<h3>numpy.msort()<\/h3>\n<p>The numpy.msort() function performs a merge sort on an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nsorted_array = np.msort(DataFlair_array)\n\nprint(\"Original Array:\", DataFlair_array)\nprint(\"Merge Sorted Array:\", sorted_array)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Original Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Merge Sorted Array: [<\/strong>1 2 3 5 8]<\/p>\n<h3>numpy.sort_complex()<\/h3>\n<p><span style=\"font-weight: 400\">The numpy.sort_complex() function sorts complex numbers based on their magnitudes.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_complex = np.array([2+3j, 1-5j, 4+2j])\nsorted_complex = np.sort_complex(DataFlair_complex)\n\nprint(\"Original Complex Array:\", DataFlair_complex)\nprint(\"Sorted Complex Array:\", sorted_complex)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Original Complex Array:<\/strong> [2.+3.j 1.-5.j 4.+2.j]<br \/>\n<strong>Sorted Complex Array:<\/strong> [1.-5.j 2.+3.j 4.+2.j]<\/p>\n<h3>numpy.partition()<\/h3>\n<p>The numpy.partition() function performs a partial sort along the specified axis.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\npartitioned_array = np.partition(DataFlair_array, 2)\n\nprint(\"Original Array:\", DataFlair_array)\nprint(\"Partitioned Array:\", partitioned_array)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Original Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Partitioned Array:<\/strong> [1 2 3 5 8]<\/p>\n<h3>numpy.argpartition()<\/h3>\n<p>The numpy.argpartition() function returns the indices that would partition an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nindices = np.argpartition(DataFlair_array, 2)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices for Partitioning:\", indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Indices for Partitioning:<\/strong> [3 1 4 0 2]<\/p>\n<h3>Numpy\u2019s Searching<\/h3>\n<p>Searching refers to the process of locating specific elements or patterns within data. NumPy&#8217;s searching functions are designed to facilitate these tasks efficiently in arrays, matrices, and multidimensional data structures.<\/p>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400\">FUNCTION<\/span><\/td>\n<td><span style=\"font-weight: 400\">DESCRIPTION<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.nanargmin()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the indices of the minimum values in the specified axis while ignoring NaN values.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.argwhere()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds the indices of array elements that are non-zero, grouping them by the element value.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.nonzero()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the indices of elements that are non-zero in the array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.flatnonzero()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns indices that are non-zero in the flattened version of the array.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.where()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns elements chosen from &#8216;x&#8217; or &#8216;y&#8217; depending on a specified condition.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.searchsorted()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Finds indices where elements should be inserted into an array to maintain order.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">numpy.extract()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the elements of an array that satisfy a given condition.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>numpy.argmax()<\/h4>\n<p>The numpy.argmax() function returns the indices of the maximum value along a specified axis.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import numpy as np\n\nDataFlair_array = np.array([5, 2, 8, 1, 3])\nmax_index = np.argmax(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Index of Maximum Value:\", max_index)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Index of Maximum Value:<\/strong> 2<\/p>\n<h4>numpy.nanargmax()<\/h4>\n<p>The numpy.nanargmax() function returns the index of the maximum value, ignoring NaN values.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, np.nan, 8, 1, 3])\nmax_index = np.nanargmax(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Index of Maximum Value (ignoring NaN):\", max_index)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 5. nan 8. 1. 3.]<br \/>\n<strong>Index of Maximum Value (ignoring NaN):<\/strong> 2<\/p>\n<h4>numpy.argmin()<\/h4>\n<p>The numpy.argmin() function returns the indices of the minimum value along a specified axis.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nmin_index = np.argmin(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Index of Minimum Value:\", min_index)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Index of Minimum Value:<\/strong> 3<\/p>\n<h4>numpy.nanargmin()<\/h4>\n<p>The numpy.nanargmin() function returns the index of the minimum value, ignoring NaN values.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, np.nan, 8, 1, 3])\nmin_index = np.nanargmin(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Index of Minimum Value (ignoring NaN):\", min_index)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 5. nan 8. 1. 3.]<br \/>\n<strong>Index of Minimum Value (ignoring NaN):<\/strong> 3<\/p>\n<h4>numpy.argwhere()<\/h4>\n<p>The numpy.argwhere() function returns the indices of elements that satisfy a given condition.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nindices = np.argwhere(DataFlair_array &gt; 2)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices of Elements &gt; 2:\", indices)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Indices of Elements &gt; 2:<\/strong> [[0]<br \/>\n[2]<br \/>\n[4]]<\/p>\n<h4>numpy.nonzero()<\/h4>\n<p>The numpy.nonzero() function returns the indices of non-zero elements in an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([0, 10, 0, 25, 30, 0])\nnonzero_indices = np.nonzero(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices of Non-zero Elements:\", nonzero_indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 0 10 0 25 30 0]<br \/>\n<strong>Indices of Non-zero Elements:<\/strong> (array([1, 3, 4]),)<\/p>\n<h4>numpy.flatnonzero()<\/h4>\n<p>The numpy.flatnonzero() function returns indices of non-zero elements in a flattened array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([0, 10, 0, 25, 30, 0])\nflat_nonzero_indices = np.flatnonzero(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices of Non-zero Elements (Flattened):\", flat_nonzero_indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 0 10 0 25 30 0]<br \/>\n<strong>Indices of Non-zero Elements (Flattened):<\/strong> [1 3 4]<\/p>\n<h4>numpy.where()<\/h4>\n<p>The numpy.where() function returns the indices of elements that satisfy a condition.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\nindices = np.where(DataFlair_array &gt; 2)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Indices of Elements &gt; 2:\", indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Indices of Elements &gt; 2:<\/strong> (array([0, 2, 4]),)<\/p>\n<h4>numpy.searchsorted()<\/h4>\n<p>The numpy.searchsorted() function conducts a binary search within a sorted array to determine the positions where elements should be added to preserve their order.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">sorted_array = np.array([1, 3, 5, 7, 9])\nindices = np.searchsorted(sorted_array, 6)\n\nprint(\"Sorted Array:\", sorted_array)\nprint(\"Index to Insert 6:\", indices)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Sorted Array:<\/strong> [1 3 5 7 9]<br \/>\n<strong>Index to Insert 6:<\/strong> 3<\/p>\n<h4>numpy.extract()<\/h4>\n<p>The numpy.extract() function returns elements from an array that satisfy a condition.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([5, 2, 8, 1, 3])\ncondition = DataFlair_array &gt; 2\nextracted_elements = np.extract(condition, DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Extracted Elements:\", extracted_elements)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [5 2 8 1 3]<br \/>\n<strong>Extracted Elements:<\/strong> [5 8 3]<\/p>\n<h3>Numpy\u2019s Counting<\/h3>\n<p>Counting in the context of data manipulation involves quantifying occurrences, frequencies, or unique values within a dataset. NumPy&#8217;s counting functions provide efficient ways to extract essential statistical insights from arrays and matrices.<\/p>\n<h4>numpy.count()<\/h4>\n<p>The numpy.count() function counts the occurrences of a specific value in an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([1, 2, 2, 3, 3, 3])\ncount_of_3 = np.count(DataFlair_array, 3)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Count of 3:\", count_of_3)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [1 2 2 3 3 3]<br \/>\n<strong>Count of 3:<\/strong> 3<\/p>\n<h4>numpy.bincount()<\/h4>\n<p>The numpy.bincount() function counts occurrences of non-negative integers in an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import numpy as np\n\nDataFlair_array = np.array([1, 2, 2, 3, 3, 3])\nbin_counts = np.bincount(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Bin Counts:\", bin_counts)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [1 2 2 3 3 3]<br \/>\n<strong>Bin Counts:<\/strong> [0 1 2 3]<\/p>\n<h4>numpy.unique()<\/h4>\n<p>The numpy.unique() function returns unique elements and their counts.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([1, 2, 2, 3, 3, 3])\nunique_elements, counts = np.unique(DataFlair_array, return_counts=True)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Unique Elements:\", unique_elements)\nprint(\"Counts:\", counts)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [1 2 2 3 3 3]<br \/>\n<strong>Unique Elements:<\/strong> [1 2 3]<br \/>\n<strong>Counts:<\/strong> [1 2 3]<\/p>\n<h4>numpy.histogram()<\/h4>\n<p>The numpy.histogram() function computes the histogram of a dataset.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([2, 5, 7, 10, 15, 20, 25, 30])\nhist, bin_edges = np.histogram(DataFlair_array, bins=[0, 10, 20, 30])\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Histogram:\", hist)\nprint(\"Bin Edges:\", bin_edges)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 2 5 7 10 15 20 25 30]<br \/>\n<strong>Histogram:<\/strong> [2 3 3]<br \/>\n<strong>Bin Edges:<\/strong> [ 0 10 20 30]<\/p>\n<h4>numpy.count_nonzero()<\/h4>\n<p>The numpy.count_nonzero() function counts the number of non-zero elements in an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([0, 10, 0, 25, 30, 0])\nnonzero_count = np.count_nonzero(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Count of Non-zero Elements:\", nonzero_count)<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Array:<\/strong> [ 0 10 0 25 30 0]<br \/>\n<strong>Count of Non-zero Elements:<\/strong> 3<\/p>\n<h4>numpy.count_zero()<\/h4>\n<p>The numpy.count_zero() function counts the number of zero elements in an array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DataFlair_array = np.array([0, 10, 0, 25, 30, 0])\nzero_count = np.count_zero(DataFlair_array)\n\nprint(\"Array:\", DataFlair_array)\nprint(\"Count of Zero Elements:\", zero_count)<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><strong>Array:<\/strong> [ 0 10 0 25 30 0]<br \/>\n<strong>Count of Zero Elements:<\/strong> 3<\/p>\n<h3>Conclusion<\/h3>\n<p>In this brief tutorial, we&#8217;ve witnessed how NumPy&#8217;s capabilities can swiftly organize, pinpoint, and quantify information. Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.<\/p>\n<p>As you delve deeper into the realm of data science, remember that NumPy&#8217;s features are your secret weapons for efficient and effective analysis. With these techniques at your disposal, you&#8217;re empowered to extract meaningful insights from your data, driving your blog&#8217;s analytics and discoveries to new heights. Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Numpy\u2019s Sorting Sorting involves arranging elements in a specific sequence based on certain criteria, such as numerical order (ascending or descending) or alphabetical order. NumPy&#8217;s sorting functions are optimized for large datasets and can&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":88974,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[385],"tags":[5247,5287,384,5288,5289],"class_list":["post-88795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-numpy-tutorials","tag-numpy","tag-numpy-sorting-searching-and-counting","tag-numpy-tutorial","tag-sorting-searching-and-counting","tag-sorting-searching-and-counting-in-numpy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Numpy Sorting, Searching, and Counting - TechVidvan<\/title>\n<meta name=\"description\" content=\"NumPy&#039;s Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Numpy Sorting, Searching, and Counting - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"NumPy&#039;s Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-07T12:30:35+00:00\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan 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":"Numpy Sorting, Searching, and Counting - TechVidvan","description":"NumPy's Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.","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:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/","og_locale":"en_US","og_type":"article","og_title":"Numpy Sorting, Searching, and Counting - TechVidvan","og_description":"NumPy's Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.","og_url":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2023-12-07T12:30:35+00:00","author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Numpy Sorting, Searching, and Counting","datePublished":"2023-12-07T12:30:35+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/"},"wordCount":919,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#primaryimage"},"thumbnailUrl":"","keywords":["numpy","numpy sorting searching and counting","numPy tutorial","sorting searching and counting","sorting searching and counting in numpy"],"articleSection":["NumPy Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/","url":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/","name":"Numpy Sorting, Searching, and Counting - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#primaryimage"},"thumbnailUrl":"","datePublished":"2023-12-07T12:30:35+00:00","description":"NumPy's Sorting enables us to identify patterns, searching helps us find critical elements, and counting unveils valuable insights about data distribution.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/numpy-sorting-searching-and-counting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Numpy Sorting, Searching, and Counting"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/88795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=88795"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/88795\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=88795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=88795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=88795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}