{"id":2870,"date":"2023-07-20T08:06:34","date_gmt":"2023-07-20T08:06:34","guid":{"rendered":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/"},"modified":"2023-07-20T08:06:34","modified_gmt":"2023-07-20T08:06:34","slug":"statistiche-riassuntive-dei-panda","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/","title":{"rendered":"Come calcolare le statistiche di riepilogo per un pandas dataframe"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare i seguenti metodi per calcolare le statistiche di riepilogo per le variabili in un DataFrame panda:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Metodo 1: calcolare le statistiche riassuntive per tutte le variabili numeriche<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">describe<\/span> ()\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 2: calcolare le statistiche di riepilogo per tutte le variabili stringa<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">describe<\/span> (include=' <span style=\"color: #ff0000;\">object<\/span> ')<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 3: calcolare le statistiche riassuntive raggruppate per una variabile<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">group_column<\/span> '). <span style=\"color: #3366ff;\">mean<\/span> ()\n\ndf. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">group_column<\/span> '). <span style=\"color: #3366ff;\">median<\/span> ()\n\ndf. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">group_column<\/span> '). <span style=\"color: #3366ff;\">max<\/span> ()\n\n...<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare ciascun metodo nella pratica con i seguenti DataFrame panda:<\/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<span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [18, 22, 19, 14, 14, 11, 20, 28, 30],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ': [5, np.nan, 7, 9, 12, 9, 9, 4, 5],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 8, 10, 6, 6, 5, 9, np.nan, 6]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n  team points assists rebounds\n0 to 18 5.0 11.0\n1 to 22 NaN 8.0\n2 A 19 7.0 10.0\n3 A 14 9.0 6.0\n4 B 14 12.0 6.0\n5 B 11 9.0 5.0\n6 B 20 9.0 9.0\n7 B 28 4.0 NaN\n8 B 30 5.0 6.0\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: calcolare le statistiche riassuntive per tutte le variabili numeriche<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come calcolare le statistiche di riepilogo per ciascuna variabile numerica nel DataFrame:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">describe<\/span> ()\n\n\t   points assists rebounds\ncount 9.000000 8.000000 8.000000\nmean 19.555556 7.500000 7.625000\nstd 6.366143 2.725541 2.199838\nmin 11.000000 4.000000 5.000000\n25% 14,000000 5,000000 6,000000\n50% 19,000000 8,000000 7,000000\n75% 22.000000 9.000000 9.250000\nmax 30.000000 12.000000 11.000000<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere le seguenti statistiche riassuntive per ciascuna delle tre variabili numeriche:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>conteggio:<\/strong> il numero di valori diversi da zero<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>media<\/strong> : il valore medio<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>std<\/strong> : la deviazione standard<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>min:<\/strong> il valore minimo<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>25%<\/strong> : il valore al 25\u00b0 percentile<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>50%<\/strong> : il valore al 50\u00b0 percentile (anche la mediana)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>75%<\/strong> : il valore al 75\u00b0 percentile<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>max<\/strong> : il valore massimo<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: calcolare le statistiche di riepilogo per tutte le variabili stringa<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come calcolare le statistiche di riepilogo per ciascuna variabile stringa nel DataFrame:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">describe<\/span> (include=' <span style=\"color: #ff0000;\">object<\/span> ')\n\n\tteam\ncount 9\nsingle 2\ntop B\nfreq 5<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere le seguenti statistiche riassuntive per la variabile stringa nel nostro DataFrame:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>count<\/strong> : il numero di valori diversi da zero<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>unique<\/strong> : il numero di valori univoci<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>in alto:<\/strong> il valore pi\u00f9 frequente<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>freq<\/strong> : il numero di valori che appaiono pi\u00f9 frequentemente<\/span><\/li>\n<\/ul>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: calcolare le statistiche riassuntive raggruppate per una variabile<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come calcolare il valore medio di tutte le variabili numeriche, raggruppate per variabile <strong>del team<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">team<\/span> '). <span style=\"color: #3366ff;\">mean<\/span> ()\n\n\tpoints assists rebounds\nteam\t\t\t\nA 18.25 7.0 8.75\nB 20.60 7.8 6.50\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">L&#8217;output mostra il valore medio delle variabili <strong>punti<\/strong> , <strong>assist<\/strong> e <strong>rimbalzi<\/strong> , raggruppate per variabile <strong>squadra<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che possiamo utilizzare una sintassi simile per calcolare una statistica riassuntiva diversa, come la mediana:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>df. <span style=\"color: #3366ff;\">groupby<\/span> (' <span style=\"color: #ff0000;\">team<\/span> '). <span style=\"color: #3366ff;\">median<\/span> ()\n\n\tpoints assists rebounds\nteam\t\t\t\nA 18.5 7.0 9.0\nB 20.0 9.0 6.0<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">L&#8217;output mostra il valore mediano delle variabili <strong>punti<\/strong> , <strong>assist<\/strong> e <strong>rimbalzi<\/strong> , raggruppate per variabile <strong>di squadra<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : puoi trovare la documentazione completa della funzione <strong>descrizione<\/strong> in panda <a href=\"https:\/\/pandas.pydata.org\/docs\/reference\/api\/pandas.DataFrame.describe.html\" target=\"_blank\" rel=\"noopener\">qui<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre attivit\u00e0 comuni dei panda:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/gruppo-di-panda-per-numero\/\" target=\"_blank\" rel=\"noopener\">Come contare gli avvistamenti di gruppo nei panda<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/massimo-per-gruppo-di-panda\/\" target=\"_blank\" rel=\"noopener\">Come trovare il valore massimo per gruppo su Pandas<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/rimuovere-i-valori-anomali-di-python\/\" target=\"_blank\" rel=\"noopener\">Come identificare i valori anomali nei panda<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare i seguenti metodi per calcolare le statistiche di riepilogo per le variabili in un DataFrame panda: Metodo 1: calcolare le statistiche riassuntive per tutte le variabili numeriche df. describe () Metodo 2: calcolare le statistiche di riepilogo per tutte le variabili stringa df. describe (include=&#8217; object &#8216;) Metodo 3: calcolare le statistiche [&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>Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.\" \/>\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\/it\/statistiche-riassuntive-dei-panda\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-20T08:06:34+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/\",\"url\":\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/\",\"name\":\"Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-20T08:06:34+00:00\",\"dateModified\":\"2023-07-20T08:06:34+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come calcolare le statistiche di riepilogo per un pandas dataframe\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology","description":"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.","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\/it\/statistiche-riassuntive-dei-panda\/","og_locale":"it_IT","og_type":"article","og_title":"Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology","og_description":"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.","og_url":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/","og_site_name":"Statorials","article_published_time":"2023-07-20T08:06:34+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/","url":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/","name":"Come calcolare le statistiche riassuntive per un Pandas DataFrame - Stology","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-20T08:06:34+00:00","dateModified":"2023-07-20T08:06:34+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come calcolare le statistiche riassuntive per un DataFrame panda, con un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/statistiche-riassuntive-dei-panda\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come calcolare le statistiche di riepilogo per un pandas dataframe"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/2870"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=2870"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/2870\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=2870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=2870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=2870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}