{"id":3207,"date":"2023-07-18T16:36:45","date_gmt":"2023-07-18T16:36:45","guid":{"rendered":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/"},"modified":"2023-07-18T16:36:45","modified_gmt":"2023-07-18T16:36:45","slug":"pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/","title":{"rendered":"Pandas: so z\u00e4hlen sie einzigartige kombinationen aus zwei spalten"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Sie k\u00f6nnen die folgende Syntax verwenden, um die Anzahl eindeutiger Kombinationen in zwei Spalten in einem Pandas-DataFrame zu z\u00e4hlen:<\/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;\">Das folgende Beispiel zeigt, wie diese Syntax in der Praxis verwendet wird.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel: Z\u00e4hlen einzigartiger Kombinationen zweier Spalten in Pandas<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Angenommen, wir haben den folgenden Pandas-DataFrame, der die <strong>Mannschaft<\/strong> und <strong>Position<\/strong> verschiedener Basketballspieler zeigt:<\/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;\">Wir k\u00f6nnen die folgende Syntax verwenden, um die Anzahl der eindeutigen <strong>Team-<\/strong> und <strong>Positionskombinationen<\/strong> zu z\u00e4hlen:<\/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;\">Aus dem Ergebnis k\u00f6nnen wir sehen:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Es gibt <strong>3<\/strong> Vorkommen der Mavs-Guard-Kombination.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Es gibt <strong>zwei<\/strong> Vorkommen der Heat-Forward-Kombination.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Es gibt <strong>zwei<\/strong> Vorkommen der Heat-Guard-Kombination.<\/span><\/li>\n<li> <span style=\"color: #000000;\">Es gibt <strong>1<\/strong> Vorkommen der Mavs-Forward-Kombination.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass Sie die Ergebnisse auch in aufsteigender oder absteigender Reihenfolge sortieren k\u00f6nnen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beispielsweise k\u00f6nnen wir den folgenden Code verwenden, um die Ergebnisse in <strong>aufsteigender<\/strong> Reihenfolge der Zahlen zu sortieren:<\/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;\">Die Ergebnisse werden jetzt nach Nummer sortiert, vom kleinsten zum gr\u00f6\u00dften.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Hinweis<\/strong> : Die vollst\u00e4ndige Dokumentation der Funktion pandas <strong>value_counts()<\/strong> finden Sie <a href=\"https:\/\/pandas.pydata.org\/docs\/reference\/api\/pandas.Series.value_counts.html\" target=\"_blank\" rel=\"noopener\">hier<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie andere h\u00e4ufige Aufgaben in Pandas ausf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/pandas-groupby-wert-zahlt\/\" target=\"_blank\" rel=\"noopener\">Pandas: So verwenden Sie GroupBy und Wertz\u00e4hlungen<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/pandas-gruppieren-nach-behaltern\/\" target=\"_blank\" rel=\"noopener\">Pandas: So verwenden Sie GroupBy mit Bin-Anzahl<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/anzahl-der-pandas-pivot-tabellen\/\" target=\"_blank\" rel=\"noopener\">Pandas: So erstellen Sie eine Pivot-Tabelle mit der Anzahl der Werte<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sie k\u00f6nnen die folgende Syntax verwenden, um die Anzahl eindeutiger Kombinationen in zwei Spalten in einem Pandas-DataFrame zu z\u00e4hlen: df[[&#8218; col1 &#8218;, &#8218; col2 &#8218;]]. value_counts (). reset_index (name=&#8216; count &#8218;) Das folgende Beispiel zeigt, wie diese Syntax in der Praxis verwendet wird. Beispiel: Z\u00e4hlen einzigartiger Kombinationen zweier Spalten in Pandas Angenommen, wir haben den [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.\" \/>\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\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/\" \/>\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 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/\",\"url\":\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/\",\"name\":\"Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-18T16:36:45+00:00\",\"dateModified\":\"2023-07-18T16:36:45+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pandas: so z\u00e4hlen sie einzigartige kombinationen aus zwei spalten\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik","description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.","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\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/","og_locale":"de_DE","og_type":"article","og_title":"Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik","og_description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.","og_url":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/","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 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/","url":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/","name":"Pandas: So z\u00e4hlen Sie einzigartige Kombinationen aus zwei Spalten \u2013 Statistik","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-18T16:36:45+00:00","dateModified":"2023-07-18T16:36:45+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Anzahl eindeutiger Kombinationen \u00fcber zwei Spalten in einem Pandas-DataFrame gez\u00e4hlt wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/pandas-zahlen-einzigartige-kombinationen-aus-zwei-spalten\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"Pandas: so z\u00e4hlen sie einzigartige kombinationen aus zwei spalten"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3207"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=3207"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/3207\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=3207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=3207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=3207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}