{"id":2206,"date":"2023-07-23T06:34:46","date_gmt":"2023-07-23T06:34:46","guid":{"rendered":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/"},"modified":"2023-07-23T06:34:46","modified_gmt":"2023-07-23T06:34:46","slug":"numpy-ndarray-object-heeft-geen-attribuutindex","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/","title":{"rendered":"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Een fout die u kunt tegenkomen bij het gebruik van NumPy is:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #ff0000;\">AttributeError <span style=\"color: #000000;\">: 'numpy.ndarray' object has no attribute 'index'\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze fout treedt op wanneer u probeert de functie <strong>index()<\/strong> te gebruiken op een NumPy-array, waarvoor geen indexkenmerken beschikbaar zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze fout in de praktijk kunt oplossen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hoe de fout te reproduceren<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we de volgende NumPy-array hebben:<\/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\n<span style=\"color: #008080;\">#create NumPy array\n<span style=\"color: #000000;\">x = np. <span style=\"color: #3366ff;\">array<\/span> ([4, 7, 3, 1, 5, 9, 9, 15, 9, 18])\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de volgende syntaxis gebruiken om de minimum- en maximumwaarden in de array te vinden:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#find minimum and maximum values of array\n<span style=\"color: #000000;\">min_val = np. <span style=\"color: #3366ff;\">min<\/span> (x)\nmax_val = np. <span style=\"color: #3366ff;\">max<\/span> (x)\n\n<span style=\"color: #008080;\">#print minimum and maximum values\n<\/span><span style=\"color: #008000;\">print<\/span> (min_val, max_val)\n\n1 18<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Stel nu dat we proberen de indexpositie van de minimum- en maximumwaarden in de array te vinden:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to print index position of minimum value\n<span style=\"color: #000000;\">x. <span style=\"color: #3366ff;\">index<\/span> (min_val)\n\n<span style=\"color: #ff0000;\">AttributeError<\/span> : 'numpy.ndarray' object has no attribute 'index'\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We ontvangen een foutmelding omdat we een <strong>index()<\/strong> -functie niet kunnen toepassen op een NumPy-array.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hoe u de fout kunt oplossen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\"><span style=\"color: #000000;\">Om de indexpositie van de minimum- en maximumwaarden in de NumPy-array te vinden, kunnen we de functie NumPywhere <strong>()<\/strong> gebruiken:<\/span><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#find index position of minimum value<\/span>\nn.p. <span style=\"color: #3366ff;\">where<\/span> (x == min_val)\n\n(array([3]),)\n\n<span style=\"color: #008080;\">#find index position of maximum value\n<\/span>n.p. <span style=\"color: #3366ff;\">where<\/span> (x == max_val)\n\n(array([9]),)\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">De minimumwaarde van de array bevindt zich op indexpositie <strong>3<\/strong> .<\/span><\/li>\n<li> <span style=\"color: #000000;\">De maximale waarde van de array bevindt zich op indexpositie <strong>9<\/strong> .<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">We kunnen dezelfde algemene syntaxis gebruiken om de indexpositie van elke waarde in een NumPy-array te vinden.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen bijvoorbeeld de volgende syntaxis gebruiken om te bepalen welke indexposities gelijk zijn aan de waarde 9 in de NumPy-array:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#find index positions that are equal to the value 9\n<\/span>n.p. <span style=\"color: #3366ff;\">where<\/span> (x == <span style=\"color: #008000;\">9<\/span> )\n\n(array([5, 6, 8]),)\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien dat de waarden op indexposities 5, 6 en 8 allemaal gelijk zijn aan <strong>9<\/strong> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende fouten in Python kunt oplossen:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/pandas-sleutelfout\/\" target=\"_blank\" rel=\"noopener\">Hoe KeyError in Panda&#8217;s te repareren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/valueerror-kan-float-nan-niet-omzetten-in-geheel-getal\/\" target=\"_blank\" rel=\"noopener\">Oplossing: ValueError: Kan float NaN niet naar int converteren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/de-operanden-konden-niet-met-de-formulieren-worden-uitgezonden\/\" target=\"_blank\" rel=\"noopener\">Oplossing: ValueError: Operanden konden niet worden uitgezonden met vormen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Een fout die u kunt tegenkomen bij het gebruik van NumPy is: AttributeError : &#8217;numpy.ndarray&#8216; object has no attribute &#8218;index&#8216; Deze fout treedt op wanneer u probeert de functie index() te gebruiken op een NumPy-array, waarvoor geen indexkenmerken beschikbaar zijn. Het volgende voorbeeld laat zien hoe u deze fout in de praktijk kunt oplossen. Hoe [&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-2206","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>Oplossing: &#039;numpy.ndarray&#039;-object heeft geen &#039;index&#039;-attribuut - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#039;numpy.ndarray&#039; heeft geen &#039;index&#039;-attribuut.\" \/>\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-ndarray-object-heeft-geen-attribuutindex\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Oplossing: &#039;numpy.ndarray&#039;-object heeft geen &#039;index&#039;-attribuut - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#039;numpy.ndarray&#039; heeft geen &#039;index&#039;-attribuut.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T06:34: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=\"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-ndarray-object-heeft-geen-attribuutindex\/\",\"url\":\"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/\",\"name\":\"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-23T06:34:46+00:00\",\"dateModified\":\"2023-07-23T06:34:46+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#39;numpy.ndarray&#39; heeft geen &#39;index&#39;-attribuut.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut\"}]},{\"@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":"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut - Statorials","description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#39;numpy.ndarray&#39; heeft geen &#39;index&#39;-attribuut.","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-ndarray-object-heeft-geen-attribuutindex\/","og_locale":"de_DE","og_type":"article","og_title":"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut - Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#39;numpy.ndarray&#39; heeft geen &#39;index&#39;-attribuut.","og_url":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/","og_site_name":"Statorials","article_published_time":"2023-07-23T06:34:46+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-ndarray-object-heeft-geen-attribuutindex\/","url":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/","name":"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-23T06:34:46+00:00","dateModified":"2023-07-23T06:34:46+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de volgende fout in NumPy kunt oplossen: Object &#39;numpy.ndarray&#39; heeft geen &#39;index&#39;-attribuut.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/numpy-ndarray-object-heeft-geen-attribuutindex\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Oplossing: &#39;numpy.ndarray&#39;-object heeft geen &#39;index&#39;-attribuut"}]},{"@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\/2206","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=2206"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2206\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=2206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=2206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=2206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}