{"id":3209,"date":"2023-07-18T16:36:45","date_gmt":"2023-07-18T16:36:45","guid":{"rendered":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/"},"modified":"2023-07-18T16:36:45","modified_gmt":"2023-07-18T16:36:45","slug":"pandas-tellen-unieke-combinaties-van-twee-kolommen","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/","title":{"rendered":"Panda&#39;s: unieke combinaties van twee kolommen tellen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende syntaxis gebruiken om het aantal unieke combinaties in twee kolommen in een pandas DataFrame te tellen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df[[' <span style=\"color: #ff0000;\">col1<\/span> ', ' <span style=\"color: #ff0000;\">col2<\/span> ']]. <span style=\"color: #3366ff;\">value_counts<\/span> (). <span style=\"color: #3366ff;\">reset_index<\/span> (name=' <span style=\"color: #ff0000;\">count<\/span> ')\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: unieke combinaties van twee kolommen tellen in Panda&#8217;s<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende panda&#8217;s DataFrame hebben dat het <strong>team<\/strong> en <strong>de positie<\/strong> van verschillende basketbalspelers toont:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#create dataFrame<\/span>\ndf = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['Mavs', 'Mavs', 'Mavs', 'Mavs',\n                            'Heat', 'Heat', 'Heat', 'Heat'],\n                   ' <span style=\"color: #ff0000;\">position<\/span> ': ['Guard', 'Guard', 'Guard', 'Forward',\n                                'Guard', 'Forward', 'Forward', 'Guard']})\n<span style=\"color: #008080;\">#view DataFrame\n<\/span>df\n\n        team position\n0 Mavs Guard\n1 Mavs Guard\n2 Mavs Guard\n3 Mavs Forward\n4 Heat Guard\n5 Heat Forward\n6 Heat Forward\n7 Heat Guard<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de volgende syntaxis gebruiken om het aantal unieke <strong>team-<\/strong> en <strong>positiecombinaties<\/strong> te tellen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df[[' <span style=\"color: #ff0000;\">team<\/span> ', ' <span style=\"color: #ff0000;\">position<\/span> ']]. <span style=\"color: #3366ff;\">value_counts<\/span> (). <span style=\"color: #3366ff;\">reset_index<\/span> (name=' <span style=\"color: #ff0000;\">count<\/span> ')\n\n        team position count\n0 Mavs Guard 3\n1 Heat Forward 2\n2 Heat Guard 2\n3 Mavs Forward 1\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we zien:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Er zijn <strong>3<\/strong> exemplaren van de Mavs-Guard-combinatie.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Er zijn <strong>2<\/strong> gevallen van de Heat-Forward-combinatie.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Er zijn <strong>2<\/strong> gevallen waarin de Heat-Guard-combinatie voorkomt.<\/span><\/li>\n<li> <span style=\"color: #000000;\">De combinatie Mavs-Forward komt <strong>1<\/strong> keer voor.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Houd er rekening mee dat u de resultaten ook in oplopende of aflopende volgorde kunt sorteren.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen bijvoorbeeld de volgende code gebruiken om de resultaten in <strong>oplopende<\/strong> volgorde van nummer te sorteren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df[[' <span style=\"color: #ff0000;\">team<\/span> ', ' <span style=\"color: #ff0000;\">position<\/span> ']]. <span style=\"color: #3366ff;\">value_counts<\/span> (ascending= <span style=\"color: #008000;\">True<\/span> ). <span style=\"color: #3366ff;\">reset_index<\/span> (name=' <span style=\"color: #ff0000;\">count<\/span> ')\n\n        team position count\n0 Mavs Forward 1\n1 Heat Forward 2\n2 Heat Guard 2\n3 Mavs Guard 3<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De resultaten worden nu gesorteerd op aantal, van klein naar groot.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Opmerking<\/strong> : u kunt <a href=\"https:\/\/pandas.pydata.org\/docs\/reference\/api\/pandas.Series.value_counts.html\" target=\"_blank\" rel=\"noopener\">hier<\/a> de volledige documentatie van de pandas <strong>value_counts()<\/strong> -functie vinden.<\/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 taken in panda&#8217;s kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/pandas-groupby-waarde-telt\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: GroupBy gebruiken en waardetellingen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/pandas-groep-per-bakken\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: GroupBy gebruiken met het aantal bakken<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/aantal-pandas-draaitabellen\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: hoe u een draaitabel met een aantal waarden maakt<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende syntaxis gebruiken om het aantal unieke combinaties in twee kolommen in een pandas DataFrame te tellen: df[[&#8218; col1 &#8218;, &#8218; col2 &#8218;]]. value_counts (). reset_index (name=&#8216; count &#8218;) Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken. Voorbeeld: unieke combinaties van twee kolommen tellen in Panda&#8217;s [&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-3209","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>Panda&#039;s: unieke combinaties van twee kolommen tellen \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame 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\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Panda&#039;s: unieke combinaties van twee kolommen tellen \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame kunt tellen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T16:36:45+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\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/\",\"url\":\"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/\",\"name\":\"Panda&#39;s: unieke combinaties van twee kolommen tellen \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-18T16:36:45+00:00\",\"dateModified\":\"2023-07-18T16:36:45+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame kunt tellen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Panda&#39;s: unieke combinaties van twee kolommen 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":"Panda&#39;s: unieke combinaties van twee kolommen tellen \u2013 Statorials","description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame 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\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/","og_locale":"de_DE","og_type":"article","og_title":"Panda&#39;s: unieke combinaties van twee kolommen tellen \u2013 Statorials","og_description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame kunt tellen.","og_url":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/","og_site_name":"Statorials","article_published_time":"2023-07-18T16:36:45+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\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/","url":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/","name":"Panda&#39;s: unieke combinaties van twee kolommen tellen \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-18T16:36:45+00:00","dateModified":"2023-07-18T16:36:45+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u het aantal unieke combinaties in twee kolommen in een Panda DataFrame kunt tellen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/pandas-tellen-unieke-combinaties-van-twee-kolommen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Panda&#39;s: unieke combinaties van twee kolommen 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\/3209","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=3209"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3209\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}