{"id":3756,"date":"2023-07-15T17:57:30","date_gmt":"2023-07-15T17:57:30","guid":{"rendered":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/"},"modified":"2023-07-15T17:57:30","modified_gmt":"2023-07-15T17:57:30","slug":"i-panda-non-contengono","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/","title":{"rendered":"Panda: come filtrare gli elementi &quot;non contiene&quot;?"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare i seguenti metodi per eseguire un filtro &#8220;Non contiene&#8221; in un DataFrame panda:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Metodo 1: filtra le righe che non contengono una stringa specifica<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>filtered_df = df[df[' <span style=\"color: #ff0000;\">my_column<\/span> ']. <span style=\"color: #3366ff;\">str<\/span> . <span style=\"color: #3366ff;\">contains<\/span> (' <span style=\"color: #ff0000;\">some_string<\/span> ') <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 2: filtra le righe che non contengono una delle numerose stringhe specifiche<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>filtered_df = df[df[' <span style=\"color: #ff0000;\">my_column<\/span> ']. <span style=\"color: #3366ff;\">str<\/span> . <span style=\"color: #3366ff;\">contains<\/span> (' <span style=\"color: #ff0000;\">string1|string2|string3<\/span> ') <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]<\/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\n<span style=\"color: #008080;\">#createDataFrame\n<span style=\"color: #000000;\">df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ': ['Nets', 'Rockets', 'Mavs', 'Spurs', 'Kings', 'Nuggets'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ': [18, 22, 19, 14, 14, 11],\n                   ' <span style=\"color: #ff0000;\">assists<\/span> ': [5, 7, 7, 9, 12, 9],\n                   ' <span style=\"color: #ff0000;\">rebounds<\/span> ': [11, 8, 10, 6, 6, 5]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n      team points assists rebounds\n0 Nets 18 5 11\n1 Rockets 22 7 8\n2 Mavs 19 7 10\n3 Spurs 14 9 6\n4 Kings 14 12 6\n5 Nuggets 11 9 5\n<\/span><\/span><\/strong><\/pre>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 1: filtrare le righe che non contengono una stringa specifica<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come filtrare il DataFrame panda per le righe la cui colonna <strong>del team<\/strong> non contiene &#8220;ets&#8221; nel nome:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#filter for rows that do not contain 'ets' in the 'team' column\n<\/span>filtered_df = df[df[' <span style=\"color: #ff0000;\">team<\/span> ']. <span style=\"color: #3366ff;\">str<\/span> . <span style=\"color: #3366ff;\">contains<\/span> (' <span style=\"color: #ff0000;\">ets<\/span> ') <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]\n\n<span style=\"color: #008080;\">#view filtered DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (filtered_df)\n\n    team points assists rebounds\n2 Mavs 19 7 10\n3 Spurs 14 9 6\n4 Kings 14 12 6<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che il DataFrame risultante non contiene righe il cui valore nella colonna <strong>del team<\/strong> contiene &#8220;ets&#8221; nel nome.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In particolare, sono stati esclusi dal DataFrame i seguenti team:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>Reti<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Razzi<\/strong><\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Pepite<\/strong><\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Nota che ciascuno di questi nomi di squadra aveva &#8220;ets&#8221; nel nome.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 2: filtrare le righe che non contengono una delle numerose stringhe specifiche<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come filtrare il DataFrame panda per le righe la cui colonna <strong>del team<\/strong> non contiene &#8220;ets&#8221; nel nome:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#filter for rows that do not contain 'ets' or 'urs' in the 'team' column\n<\/span>filtered_df = df[df[' <span style=\"color: #ff0000;\">team<\/span> ']. <span style=\"color: #3366ff;\">str<\/span> . <span style=\"color: #3366ff;\">contains<\/span> (' <span style=\"color: #ff0000;\">ets|urs<\/span> ') <span style=\"color: #800080;\">==<\/span> <span style=\"color: #008000;\">False<\/span> ]\n\n<span style=\"color: #008080;\">#view filtered DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (filtered_df)\n\n    team points assists rebounds\n2 Mavs 19 7 10\n4 Kings 14 12 6<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che il DataFrame risultante non contiene righe il cui valore nella colonna <strong>del team<\/strong> contiene &#8220;ets&#8221; o &#8220;urs&#8221; nel nome.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : il <strong>|<\/strong> L&#8217;operatore significa &#8220;OR&#8221; in panda.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre operazioni di filtro comuni nei panda:<\/span><\/p>\n<p> Come filtrare un Pandas DataFrame in base ai valori delle colonne<br \/> Come filtrare le righe Pandas DataFrame per data<br \/><a href=\"https:\/\/statorials.org\/it\/i-panda-filtrano-piu-condizioni\/\" target=\"_blank\" rel=\"noopener\">Come filtrare un Pandas DataFrame su pi\u00f9 condizioni<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare i seguenti metodi per eseguire un filtro &#8220;Non contiene&#8221; in un DataFrame panda: Metodo 1: filtra le righe che non contengono una stringa specifica filtered_df = df[df[&#8216; my_column &#8216;]. str . contains (&#8216; some_string &#8216;) == False ] Metodo 2: filtra le righe che non contengono una delle numerose stringhe specifiche filtered_df [&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 filtrare &quot;Non contiene&quot; - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, 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\/i-panda-non-contengono\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Panda: come filtrare &quot;Non contiene&quot; - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, con un esempio.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/i-panda-non-contengono\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-15T17:57:30+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-non-contengono\/\",\"url\":\"https:\/\/statorials.org\/it\/i-panda-non-contengono\/\",\"name\":\"Panda: come filtrare &quot;Non contiene&quot; - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-15T17:57:30+00:00\",\"dateModified\":\"2023-07-15T17:57:30+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, con un esempio.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/i-panda-non-contengono\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/i-panda-non-contengono\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/i-panda-non-contengono\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Panda: come filtrare gli elementi &quot;non contiene&quot;?\"}]},{\"@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 filtrare &quot;Non contiene&quot; - Statorials","description":"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, 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\/i-panda-non-contengono\/","og_locale":"it_IT","og_type":"article","og_title":"Panda: come filtrare &quot;Non contiene&quot; - Statorials","og_description":"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, con un esempio.","og_url":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/","og_site_name":"Statorials","article_published_time":"2023-07-15T17:57:30+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-non-contengono\/","url":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/","name":"Panda: come filtrare &quot;Non contiene&quot; - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-15T17:57:30+00:00","dateModified":"2023-07-15T17:57:30+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come filtrare le righe da un DataFrame panda che non contengono una stringa particolare, con un esempio.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/i-panda-non-contengono\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/i-panda-non-contengono\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Panda: come filtrare gli elementi &quot;non contiene&quot;?"}]},{"@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\/3756"}],"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=3756"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/3756\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=3756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=3756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=3756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}