{"id":1735,"date":"2023-07-25T05:02:59","date_gmt":"2023-07-25T05:02:59","guid":{"rendered":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/"},"modified":"2023-07-25T05:02:59","modified_gmt":"2023-07-25T05:02:59","slug":"i-panda-rilasciano-righe-con-valore","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/","title":{"rendered":"Panda: come eliminare righe contenenti un valore specifico"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi per eliminare righe in un DataFrame panda che contengono un valore specifico in una determinata colonna:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#drop rows that contain specific 'value' in 'column_name'<\/span>\ndf = df[df. <span style=\"color: #3366ff;\">column_name<\/span> <span style=\"color: #993300;\">!=<\/span> <span style=\"color: #008000;\">value<\/span> ]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">\u00c8 possibile utilizzare la seguente sintassi per eliminare righe in un DataFrame panda che contengono qualsiasi valore in un determinato elenco:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define values<\/span>\nvalues = [value1, value2, value3, ...]\n\n<span style=\"color: #008080;\">#drop rows that contain any value in the list\n<\/span>df = df[df. <span style=\"color: #3366ff;\">column_name<\/span> . <span style=\"color: #3366ff;\">isin<\/span> (values) <span style=\"color: #993300;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Gli esempi seguenti mostrano come utilizzare questa sintassi nella pratica.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 1: Elimina righe contenenti un valore specifico<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come eliminare tutte le righe contenenti un valore specifico in una colonna:<\/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\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['Mavs', 'Lakers', 'Spurs', 'Cavs'],\n                   ' <span style=\"color: #ff0000;\">name<\/span> ': ['Dirk', 'Kobe', 'Tim', 'Lebron'],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 7, 14, 7],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [26, 31, 22, 29]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span>df\n\n        team name rebound points\n0 Mavs Dirk 11 26\n1 Lakers Kobe 7 31\n2 Spurs Tim 14 22\n3 Cavs LeBron 7 29\n\n<span style=\"color: #008080;\">#drop any rows that have 7 in the rebounds column\n<\/span>df = df[df. <span style=\"color: #3366ff;\">rebounds<\/span> <span style=\"color: #993300;\">!=<\/span> <span style=\"color: #008000;\">7<\/span> ]\n\n<span style=\"color: #008080;\">#view resulting DataFrame<\/span>\ndf\n\n        team name rebound points\n0 Mavs Dirk 11 26\n2 Spurs Tim 14 22<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 2: rimozione di righe contenenti valori in un elenco<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come rimuovere tutte le righe dal DataFrame che contengono un valore in un elenco:<\/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\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['Mavs', 'Lakers', 'Spurs', 'Cavs'],\n                   ' <span style=\"color: #ff0000;\">name<\/span> ': ['Dirk', 'Kobe', 'Tim', 'Lebron'],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 7, 14, 7],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [26, 31, 22, 29]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span>df\n\n        team name rebound points\n0 Mavs Dirk 11 26\n1 Lakers Kobe 7 31\n2 Spurs Tim 14 22\n3 Cavs LeBron 7 29\n\n<span style=\"color: #008080;\">#define list of values<\/span>\nvalues = [7, 11]\n\n<span style=\"color: #008080;\">#drop any rows that have 7 or 11 in the rebounds column\n<\/span>df = df[df. <span style=\"color: #3366ff;\">rebounds<\/span> . <span style=\"color: #3366ff;\">isin<\/span> (values) <span style=\"color: #993300;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]\n\n<span style=\"color: #008080;\">#view resulting DataFrame<\/span>\ndf\n\n        team name rebound points\n2 Spurs Tim 14 22<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Esempio 3: rimozione di righe contenenti valori specifici in pi\u00f9 colonne<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come rimuovere righe dal DataFrame che contengono un valore specifico in una delle numerose colonne:<\/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\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['Mavs', 'Lakers', 'Spurs', 'Cavs'],\n                   ' <span style=\"color: #ff0000;\">name<\/span> ': ['Dirk', 'Kobe', 'Tim', 'Lebron'],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 7, 14, 7],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [26, 31, 22, 29]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span>df\n\n        team name rebound points\n0 Mavs Dirk 11 26\n1 Lakers Kobe 7 31\n2 Spurs Tim 14 22\n3 Cavs LeBron 7 29\n\n<span style=\"color: #008080;\">#drop any rows that have 11 in the rebounds column or 31 in the points column\n<\/span>df = df[(df. <span style=\"color: #3366ff;\">rebounds<\/span> <span style=\"color: #993300;\">!=<\/span> <span style=\"color: #008000;\">11<\/span> ) &amp; (df. <span style=\"color: #3366ff;\">points<\/span> <span style=\"color: #993300;\">!=<\/span> <span style=\"color: #008000;\">31<\/span> )]\n\n<span style=\"color: #008080;\">#view resulting DataFrame\n<\/span>df\n\nteam name rebound points\n2 Spurs Tim 14 22\n3 Cavs LeBron 7 29\n<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/i-panda-rilasciano-una-riga-per-indice\/\" target=\"_blank\" rel=\"noopener\">Come eliminare le righe per indice in Pandas<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/i-panda-rilasciano-colonna-per-indice\/\" target=\"_blank\" rel=\"noopener\">Come eliminare le colonne per indice in Pandas<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-che-contengono-stringhe\/\" target=\"_blank\" rel=\"noopener\">Come eliminare righe contenenti una stringa specifica in Pandas<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare la seguente sintassi per eliminare righe in un DataFrame panda che contengono un valore specifico in una determinata colonna: #drop rows that contain specific &#8216;value&#8217; in &#8216;column_name&#8217; df = df[df. column_name != value ] \u00c8 possibile utilizzare la seguente sintassi per eliminare righe in un DataFrame panda che contengono qualsiasi valore in [&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>Panda: come eliminare righe contenenti un valore specifico<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.\" \/>\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\/i-panda-rilasciano-righe-con-valore\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Panda: come eliminare righe contenenti un valore specifico\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T05:02:59+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\/i-panda-rilasciano-righe-con-valore\/\",\"url\":\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/\",\"name\":\"Panda: come eliminare righe contenenti un valore specifico\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-25T05:02:59+00:00\",\"dateModified\":\"2023-07-25T05:02:59+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Panda: come eliminare righe contenenti un valore specifico\"}]},{\"@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":"Panda: come eliminare righe contenenti un valore specifico","description":"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.","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\/i-panda-rilasciano-righe-con-valore\/","og_locale":"it_IT","og_type":"article","og_title":"Panda: come eliminare righe contenenti un valore specifico","og_description":"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.","og_url":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/","og_site_name":"Statorials","article_published_time":"2023-07-25T05:02:59+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\/i-panda-rilasciano-righe-con-valore\/","url":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/","name":"Panda: come eliminare righe contenenti un valore specifico","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-25T05:02:59+00:00","dateModified":"2023-07-25T05:02:59+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come eliminare righe da un DataFrame panda contenente valori specifici, inclusi diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/i-panda-rilasciano-righe-con-valore\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Panda: come eliminare righe contenenti un valore specifico"}]},{"@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\/1735"}],"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=1735"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1735\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}