{"id":2188,"date":"2023-07-23T08:16:08","date_gmt":"2023-07-23T08:16:08","guid":{"rendered":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/"},"modified":"2023-07-23T08:16:08","modified_gmt":"2023-07-23T08:16:08","slug":"panda-typeerror-nessun-dato-numerico-da-tracciare","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/","title":{"rendered":"Come risolvere il problema in panda: typeerror: nessun dato numerico da tracciare"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Un errore che potresti riscontrare quando usi i panda \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #ff0000;\">TypeError<\/span> : no numeric data to plot<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Questo errore si verifica quando si tenta di tracciare valori da un DataFrame panda, ma non ci sono valori numerici da tracciare.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Questo errore si verifica in genere quando si ritiene che una determinata colonna nel DataFrame sia numerica, ma risulta essere un tipo di dati diverso.<\/span><\/p>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come correggere questo errore nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Come riprodurre l&#8217;errore<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Supponiamo di avere i seguenti panda DataFrame:<\/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;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['A', 'A', 'B', 'B', 'B'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': ['5', '7', '7', '9', '12'],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': ['11', '8', '10', '6', '6'],\n                   ' <span style=\"color: #ff0000;\">blocks<\/span> ': ['4', '7', '7', '6', '5']})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span>df\n\n\tteam points rebound blocks\n0 A 5 11 4\n1 To 7 8 7\n2 B 7 10 7\n3 B 9 6 6\n4 B 12 6 5\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Supponiamo ora di provare a creare un grafico lineare per le tre variabili che riteniamo numeriche: punti, rimbalzi e blocchi:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to create line plot for points, rebounds, and blocks\n<span style=\"color: #000000;\">df[[' <span style=\"color: #ff0000;\">points<\/span> ', ' <span style=\"color: #ff0000;\">rebounds<\/span> ', ' <span style=\"color: #ff0000;\">blocks<\/span> ']]. <span style=\"color: #3366ff;\">plot<\/span> ()\n\n<span style=\"color: #ff0000;\">ValueError<\/span> : no numeric data to plot\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Riceviamo un errore perch\u00e9 nessuna di queste colonne \u00e8 effettivamente numerica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Come correggere l&#8217;errore<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Possiamo usare la funzione <strong>dtypes<\/strong> per vedere a quale tipo di dati appartiene ciascuna colonna nel nostro DataFrame:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display data type of each column in DataFrame\n<span style=\"color: #000000;\">df. <span style=\"color: #3366ff;\">dtypes\n\n<span style=\"color: #000000;\">team object\npoints object\nrebound object\nblocks object\ndtype:object\n<\/span><\/span><\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo vedere che nessuna delle colonne nel DataFrame \u00e8 numerica.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Possiamo usare la funzione <strong>.astype()<\/strong> per convertire colonne specifiche in valori numerici:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#convert points, rebounds, and blocks columns to numeric\n<span style=\"color: #000000;\">df[' <span style=\"color: #ff0000;\">points<\/span> ']=df[' <span style=\"color: #ff0000;\">points<\/span> ']. <span style=\"color: #3366ff;\">astype<\/span> (float)\ndf[' <span style=\"color: #ff0000;\">rebounds<\/span> ']=df[' <span style=\"color: #ff0000;\">rebounds<\/span> ']. <span style=\"color: #3366ff;\">astype<\/span> (float)\ndf[' <span style=\"color: #ff0000;\">blocks<\/span> ']=df[' <span style=\"color: #ff0000;\">blocks<\/span> ']. <span style=\"color: #3366ff;\">astype<\/span> (float)<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Possiamo quindi riutilizzare la funzione <strong>plot()<\/strong> :<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#create line plot for points, rebounds, and blocks\n<span style=\"color: #000000;\">df[[' <span style=\"color: #ff0000;\">points<\/span> ', ' <span style=\"color: #ff0000;\">rebounds<\/span> ', ' <span style=\"color: #ff0000;\">blocks<\/span> ']]. <span style=\"color: #3366ff;\">plot<\/span> ()<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-20172 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/flotteur1.png\" alt=\"\" width=\"530\" height=\"351\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Siamo in grado di creare con successo un grafico lineare per punti, rimbalzi e blocchi perch\u00e9 ogni variabile ora \u00e8 numerica.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Possiamo verificarlo utilizzando nuovamente la funzione <strong>dtypes<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#display data type of each column in DataFrame\n<span style=\"color: #000000;\">df. <span style=\"color: #3366ff;\">dtypes\n\n<span style=\"color: #000000;\">team object\nfloat64 points\nrebounds float64\nblocks float64\ndtype:object\n<\/span><\/span><\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come correggere altri errori comuni in Python:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/errore-chiave-panda\/\" target=\"_blank\" rel=\"noopener\">Come correggere l&#8217;errore chiave nei Panda<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/valueerror-non-puo-convertire-float-nan-in-intero\/\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema: ValueError: impossibile convertire float NaN in int<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/non-e-stato-possibile-trasmettere-gli-operandi-con-i-moduli\/\" target=\"_blank\" rel=\"noopener\">Come risolvere il problema: ValueError: non \u00e8 stato possibile trasmettere gli operandi con le forme<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Un errore che potresti riscontrare quando usi i panda \u00e8: TypeError : no numeric data to plot Questo errore si verifica quando si tenta di tracciare valori da un DataFrame panda, ma non ci sono valori numerici da tracciare. Questo errore si verifica in genere quando si ritiene che una determinata colonna nel DataFrame sia [&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 risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.\" \/>\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\/panda-typeerror-nessun-dato-numerico-da-tracciare\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T08:16:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/flotteur1.png\" \/>\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\/panda-typeerror-nessun-dato-numerico-da-tracciare\/\",\"url\":\"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/\",\"name\":\"Come risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-23T08:16:08+00:00\",\"dateModified\":\"2023-07-23T08:16:08+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come risolvere il problema in panda: typeerror: nessun dato numerico da tracciare\"}]},{\"@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 risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale","description":"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.","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\/panda-typeerror-nessun-dato-numerico-da-tracciare\/","og_locale":"it_IT","og_type":"article","og_title":"Come risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale","og_description":"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.","og_url":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/","og_site_name":"Statorials","article_published_time":"2023-07-23T08:16:08+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/flotteur1.png"}],"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\/panda-typeerror-nessun-dato-numerico-da-tracciare\/","url":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/","name":"Come risolvere il problema in Panda: TypeError: nessun dato numerico da tracciare - Statoriale","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-23T08:16:08+00:00","dateModified":"2023-07-23T08:16:08+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come correggere il seguente errore nei panda: TypeError: nessun dato numerico da tracciare.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/panda-typeerror-nessun-dato-numerico-da-tracciare\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come risolvere il problema in panda: typeerror: nessun dato numerico da tracciare"}]},{"@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\/2188"}],"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=2188"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/2188\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=2188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=2188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=2188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}