{"id":4302,"date":"2023-07-12T04:18:46","date_gmt":"2023-07-12T04:18:46","guid":{"rendered":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/"},"modified":"2023-07-12T04:18:46","modified_gmt":"2023-07-12T04:18:46","slug":"numpy-tel-nullen","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/","title":{"rendered":"Numpy: hoe het aantal elementen gelijk aan nul te tellen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende basissyntaxis gebruiken om het aantal nulelementen in een NumPy-array te tellen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\nn.p. <span style=\"color: #3366ff;\">count_nonzero<\/span> (my_array <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">0<\/span> )\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Dit specifieke voorbeeld retourneert het aantal elementen gelijk aan nul in de NumPy-array genaamd <strong>my_array<\/strong> .<\/span><\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: Tel het aantal elementen gelijk aan nul in de NumPy-array<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u de functie <strong>count_nonzero()<\/strong> gebruikt om het aantal elementen in een NumPy-array gelijk aan nul te tellen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<\/span>\n#create NumPy array\n<span style=\"color: #000000;\">my_array = np. <span style=\"color: #3366ff;\">array<\/span> ([2, 0, 0, 4, 5, 9, 12, 0, 4, 13, 15, 19])<\/span>\n\n#count number of values in array equal to zero\n<\/span>n.p. <span style=\"color: #3366ff;\">count_nonzero<\/span> (my_array <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">0<\/span> )\n\n3<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit de uitvoer kunnen we zien dat <strong>3<\/strong> waarden in de NumPy-array nul zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen handmatig naar de NumPy-array kijken om te verifi\u00ebren dat er inderdaad drie elementen gelijk aan nul in de array zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Als u in plaats daarvan het aantal <em>niet-nul<\/em> elementen wilt tellen, kunt u de functie <strong>count_nonzero()<\/strong> als volgt gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#create NumPy array\n<\/span>my_array = np. <span style=\"color: #3366ff;\">array<\/span> ([2, 0, 0, 4, 5, 9, 12, 0, 4, 13, 15, 19])\n\n<span style=\"color: #008080;\">#count number of values in array not equal to zero\n<\/span>n.p. <span style=\"color: #3366ff;\">count_nonzero<\/span> (my_array)\n\n9<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit de uitvoer kunnen we zien dat <strong>9<\/strong> waarden in de NumPy-array niet gelijk zijn aan nul.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Opmerking<\/strong> : als u NaN-waarden in uw NumPy-array heeft, telt de functie <strong>count_nonzero()<\/strong> elke NaN-waarde als een niet-nul element.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende bewerkingen in Python uitvoert:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/digitale-modus\/\" target=\"_blank\" rel=\"noopener\">Hoe de modus van de NumPy-array te berekenen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/digitale-kaart\/\" target=\"_blank\" rel=\"noopener\">Hoe een functie aan een NumPy-array toe te wijzen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/numpy-sorteer-array-op-kolom\/\" target=\"_blank\" rel=\"noopener\">Hoe een NumPy-array op kolom te sorteren<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende basissyntaxis gebruiken om het aantal nulelementen in een NumPy-array te tellen: import numpy as np n.p. count_nonzero (my_array == 0 ) Dit specifieke voorbeeld retourneert het aantal elementen gelijk aan nul in de NumPy-array genaamd my_array . Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-4302","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-12T04:18:46+00:00\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/\",\"url\":\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/\",\"name\":\"NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-12T04:18:46+00:00\",\"dateModified\":\"2023-07-12T04:18:46+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Numpy: hoe het aantal elementen gelijk aan nul te tellen\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials","description":"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.","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:\/\/statorials.org\/nl\/numpy-tel-nullen\/","og_locale":"de_DE","og_type":"article","og_title":"NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.","og_url":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/","og_site_name":"Statorials","article_published_time":"2023-07-12T04:18:46+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/","url":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/","name":"NumPy: hoe het aantal elementen gelijk aan nul te tellen - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-12T04:18:46+00:00","dateModified":"2023-07-12T04:18:46+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe je het aantal elementen gelijk aan nul kunt tellen in NumPy, met verschillende voorbeelden.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/numpy-tel-nullen\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/numpy-tel-nullen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Numpy: hoe het aantal elementen gelijk aan nul te tellen"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=4302"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4302\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=4302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=4302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=4302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}