{"id":4303,"date":"2023-07-12T04:11:33","date_gmt":"2023-07-12T04:11:33","guid":{"rendered":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/"},"modified":"2023-07-12T04:11:33","modified_gmt":"2023-07-12T04:11:33","slug":"numpy-telling-waar","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/","title":{"rendered":"Numpy: het aantal elementen tellen dat gelijk is aan true"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende basissyntaxis gebruiken om het aantal elementen gelijk aan <strong>True<\/strong> 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)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Dit specifieke voorbeeld retourneert het aantal elementen gelijk aan <strong>True<\/strong> in de NumPy-array genaamd <strong>my_array<\/strong> .<\/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 True 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 True 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: #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> ([True, False, False, False, True, True, False, True, True])\n\n<span style=\"color: #008080;\">#count number of values in array equal to True\n<\/span>n.p. <span style=\"color: #3366ff;\">count_nonzero<\/span> (my_array)\n\n5<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit de uitvoer kunnen we zien dat <strong>5<\/strong> waarden van de NumPy-array gelijk zijn aan <strong>True<\/strong> .<\/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 voor <strong>True<\/strong> in de array voorkomen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Als u in plaats daarvan het aantal elementen gelijk aan <strong>False<\/strong> wilt tellen, kunt u de resultaten van de functie <strong>count_nonzero()<\/strong> als volgt aftrekken van de functie <strong>size()<\/strong> :<\/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> ([True, False, False, False, True, True, False, True, True])\n\n<span style=\"color: #008080;\">#count number of values in array equal to False\n<\/span>n.p. <span style=\"color: #3366ff;\">size<\/span> (my_array) - np. <span style=\"color: #3366ff;\">count_nonzero<\/span> (my_array)\n\n4<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit de uitvoer kunnen we zien dat <strong>4<\/strong> waarden van de NumPy-array gelijk zijn aan <strong>False<\/strong> .<\/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 element dat gelijk is aan True.<\/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 elementen gelijk aan True in een NumPy-array te tellen: import numpy as np n.p. count_nonzero (my_array) Dit specifieke voorbeeld retourneert het aantal elementen gelijk aan True 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-4303","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 te tellen dat gelijk is aan True - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.\" \/>\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-telling-waar\/\" \/>\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 te tellen dat gelijk is aan True - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-12T04:11:33+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=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/\",\"url\":\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/\",\"name\":\"NumPy: Hoe het aantal elementen te tellen dat gelijk is aan True - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-12T04:11:33+00:00\",\"dateModified\":\"2023-07-12T04:11:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/numpy-telling-waar\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Numpy: het aantal elementen tellen dat gelijk is aan true\"}]},{\"@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 te tellen dat gelijk is aan True - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.","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-telling-waar\/","og_locale":"de_DE","og_type":"article","og_title":"NumPy: Hoe het aantal elementen te tellen dat gelijk is aan True - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.","og_url":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/","og_site_name":"Statorials","article_published_time":"2023-07-12T04:11:33+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/","url":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/","name":"NumPy: Hoe het aantal elementen te tellen dat gelijk is aan True - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-12T04:11:33+00:00","dateModified":"2023-07-12T04:11:33+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal elementen gelijk aan True in een NumPy-array kunt tellen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/numpy-telling-waar\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/numpy-telling-waar\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Numpy: het aantal elementen tellen dat gelijk is aan true"}]},{"@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\/4303","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=4303"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/4303\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=4303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=4303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=4303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}