{"id":3577,"date":"2023-07-16T18:08:36","date_gmt":"2023-07-16T18:08:36","guid":{"rendered":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/"},"modified":"2023-07-16T18:08:36","modified_gmt":"2023-07-16T18:08:36","slug":"pandas-groepsgewijs-beschrijven","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/","title":{"rendered":"Panda&#39;s: beschrijven() gebruiken per groep"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de functie <strong>beschrijven()<\/strong> gebruiken om beschrijvende statistieken te genereren voor variabelen in een pandas DataFrame.<\/span><\/p>\n<p> <span style=\"color: #000000;\">U kunt de volgende basissyntaxis gebruiken om de functie <strong>beschrijven()<\/strong> te gebruiken met de functie <strong>groupby()<\/strong> in panda&#8217;s:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">group_var<\/span> ')[' <span style=\"color: #ff0000;\">values_var<\/span> ']. <span style=\"color: #3366ff;\">describe<\/span> ()\n<\/strong><\/span><\/pre>\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: gebruik beschrijven() per groep in Panda&#8217;s<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende panda&#8217;s DataFrame hebben dat informatie bevat over basketbalspelers van twee verschillende teams:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#createDataFrame<\/span>\ndf = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [8, 12, 14, 14, 15, 22, 27, 24],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ':[2, 2, 3, 5, 7, 6, 8, 12]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n  team points assists\n0 to 8 2\n1 to 12 2\n2 to 14 3\n3 to 14 5\n4 B 15 7\n5 B 22 6\n6 B 27 8\n7 B 24 12<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de functie <strong>beschrijven()<\/strong> gebruiken met de functie <strong>groupby()<\/strong> om de waarden in de <strong>puntenkolom<\/strong> voor elk <strong>team<\/strong> samen te vatten:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#summarize points by team\n<span style=\"color: #000000;\">df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">team<\/span> ')[' <span style=\"color: #ff0000;\">points<\/span> ']. <span style=\"color: #3366ff;\">describe<\/span> ()\n<\/span>\n<\/span>count mean std min 25% 50% 75% max\nteam\t\t\t\t\t\t\t\t\nA 4.0 12.0 2.828427 8.0 11.00 13.0 14.00 14.0\nB 4.0 22.0 5.099020 15.0 20.25 23.0 24.75 27.0<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we de volgende waarden zien voor de <strong>puntenvariabele<\/strong> voor elk team:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>aantal<\/strong> (aantal observaties)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>gemiddeld<\/strong> (gemiddelde puntwaarde)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>std<\/strong> (standaardafwijking van puntwaarden)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>min<\/strong> (minimale puntwaarde)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>25<\/strong> % (25e percentiel van punten)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>50<\/strong> % (50e percentiel (dwz mediaan) van punten)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>75<\/strong> % (75e percentiel van punten)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>max<\/strong> (maximale puntwaarde)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Als u wilt dat de resultaten worden weergegeven in DataFrame-indeling, kunt u het argument <strong>reset_index()<\/strong> gebruiken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#summarize points by team\n<span style=\"color: #000000;\">df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">team<\/span> ')[' <span style=\"color: #ff0000;\">points<\/span> ']. <span style=\"color: #3366ff;\">describe<\/span> (). <span style=\"color: #3366ff;\">reset_index<\/span> ()<\/span><\/span><\/strong><span style=\"color: #000000;\"><strong>\n\n        team count mean std min 25% 50% 75% max\n0 A 4.0 12.0 2.828427 8.0 11.00 13.0 14.00 14.0\n1 B 4.0 22.0 5.099020 15.0 20.25 23.0 24.75 27.0\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">De <strong>teamvariabele<\/strong> is nu een kolom in het DataFrame en de indexwaarden zijn 0 en 1.<\/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 panda&#8217;s kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/cumulatieve-som-pandas-per-groep\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: hoe bereken je de cumulatieve som per groep<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/pandas-groeperen-per-telling-uniek\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: unieke waarden per groep tellen<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-correlatie\/\" target=\"_blank\" rel=\"noopener\">Panda&#8217;s: hoe de correlatie per groep te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de functie beschrijven() gebruiken om beschrijvende statistieken te genereren voor variabelen in een pandas DataFrame. U kunt de volgende basissyntaxis gebruiken om de functie beschrijven() te gebruiken met de functie groupby() in panda&#8217;s: df. groupby (&#8218; group_var &#8218;)[&#8218; values_var &#8218;]. describe () Het volgende voorbeeld laat zien hoe u deze syntaxis in de [&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-3577","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: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.\" \/>\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-groepsgewijs-beschrijven\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Panda&#039;s: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-16T18:08:36+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-groepsgewijs-beschrijven\/\",\"url\":\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/\",\"name\":\"Panda&#39;s: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-16T18:08:36+00:00\",\"dateModified\":\"2023-07-16T18:08:36+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Panda&#39;s: beschrijven() gebruiken per groep\"}]},{\"@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: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials","description":"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.","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-groepsgewijs-beschrijven\/","og_locale":"de_DE","og_type":"article","og_title":"Panda&#39;s: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials","og_description":"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.","og_url":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/","og_site_name":"Statorials","article_published_time":"2023-07-16T18:08:36+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-groepsgewijs-beschrijven\/","url":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/","name":"Panda&#39;s: Hoe de methode beschrijven() per groep te gebruiken \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-16T18:08:36+00:00","dateModified":"2023-07-16T18:08:36+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt uitgelegd hoe u de functie beschrijven() voor elke groep in een pandas DataFrame gebruikt, inclusief een voorbeeld.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/pandas-groepsgewijs-beschrijven\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Panda&#39;s: beschrijven() gebruiken per groep"}]},{"@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\/3577","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=3577"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3577\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}