{"id":4087,"date":"2023-07-13T17:02:22","date_gmt":"2023-07-13T17:02:22","guid":{"rendered":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/"},"modified":"2023-07-13T17:02:22","modified_gmt":"2023-07-13T17:02:22","slug":"i-panda-leggono-le-righe-saltate-di-excel","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/","title":{"rendered":"Panda: come saltare le righe durante la lettura di un file excel"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare i seguenti metodi per saltare le righe durante la lettura di un file Excel in un DataFrame panda:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Metodo 1: salta una riga specifica<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#import DataFrame and skip row in index position 2\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">my_data.xlsx<\/span> ', skiprows=[ <span style=\"color: #008000;\">2<\/span> ])\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 2: ignorare pi\u00f9 righe specifiche<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#import DataFrame and skip rows in index positions 2 and 4\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">my_data.xlsx<\/span> ' <span style=\"color: #008000;\">, skiprows=[2,4<\/span> <span style=\"color: #008000;\">]<\/span> )<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Metodo 3: ignora le prime N righe<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#import DataFrame and skip first 2 rows\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">my_data.xlsx<\/span> ', skiprows= <span style=\"color: #008000;\">2<\/span> )<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">I seguenti esempi mostrano come utilizzare ciascun metodo nella pratica con il seguente file Excel chiamato <strong>player_data.xlsx<\/strong> :<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-32506 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sauter-excel1.png\" alt=\"\" width=\"497\" height=\"457\" srcset=\"\" sizes=\"\"><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 1: ignora una riga specifica<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo utilizzare il seguente codice per importare il file Excel e ignorare la riga nella posizione dell&#8217;indice 2:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <b><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#import DataFrame and skip row in index position 2\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">player_data.xlsx<\/span> ', skiprows=[ <span style=\"color: #008000;\">2<\/span> ])\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n  team points rebound assists\n0 to 24 8 5\n1 C 15 4 7\n2 D 19 4 8\n3 E 32 6 8\n4 F 13 7 9\n<\/b><\/pre>\n<p> <span style=\"color: #000000;\">Si noti che la riga nella posizione dell&#8217;indice 2 (con la squadra &#8220;B&#8221;) \u00e8 stata ignorata durante l&#8217;importazione del file Excel nel DataFrame panda.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : la prima riga del file Excel \u00e8 considerata riga 0.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 2: ignorare pi\u00f9 righe specifiche<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo utilizzare il seguente codice per importare il file Excel e ignorare le righe nelle posizioni dell&#8217;indice 2 e 4:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <b><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#import DataFrame and skip rows in index positions 2 and 4\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">player_data.xlsx<\/span> ', skiprows=[ <span style=\"color: #008000;\">2,4<\/span> ] <span style=\"color: #008000;\">)<\/span>\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n  team points rebound assists\n0 to 24 8 5\n1 C 15 4 7\n2 E 32 6 8\n3 F 13 7 9\n<\/b><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che le righe nelle posizioni dell&#8217;indice 2 e 4 (con le squadre &#8220;B&#8221; e &#8220;D&#8221;) sono state ignorate durante l&#8217;importazione del file Excel nel DataFrame panda.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio 3: ignora le prime N righe<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Possiamo utilizzare il seguente codice per importare il file Excel e ignorare le prime due righe:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <b><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#import DataFrame and skip first 2 rows\n<\/span>df = pd. <span style=\"color: #3366ff;\">read_excel<\/span> (' <span style=\"color: #ff0000;\">player_data.xlsx<\/span> ', skiprows= <span style=\"color: #008000;\">2<\/span> )\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n   B 20 12 3\n0 C 15 4 7\n1 D 19 4 8\n2 E 32 6 8\n3 F 13 7 9\n<\/b><\/pre>\n<p> <span style=\"color: #000000;\">Tieni presente che le prime due righe del file Excel sono state saltate e la successiva riga disponibile (con la squadra &#8220;B&#8221;) \u00e8 diventata la riga di intestazione del DataFrame.<\/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 attivit\u00e0 comuni in Python:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/it\/i-panda-leggono-excel\/\" target=\"_blank\" rel=\"noopener\">Come leggere file Excel con Panda<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/esportare-il-dataframe-panda-in-excel\/\" target=\"_blank\" rel=\"noopener\">Come esportare Pandas DataFrame in Excel<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/tabella-numpy-in-csv\/\">Come esportare un array NumPy in un file CSV<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare i seguenti metodi per saltare le righe durante la lettura di un file Excel in un DataFrame panda: Metodo 1: salta una riga specifica #import DataFrame and skip row in index position 2 df = pd. read_excel (&#8216; my_data.xlsx &#8216;, skiprows=[ 2 ]) Metodo 2: ignorare pi\u00f9 righe specifiche #import DataFrame and [&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 saltare le righe durante la lettura di un file Excel - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con 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-leggono-le-righe-saltate-di-excel\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Panda: come saltare le righe durante la lettura di un file Excel - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con diversi esempi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-13T17:02:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sauter-excel1.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\/i-panda-leggono-le-righe-saltate-di-excel\/\",\"url\":\"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/\",\"name\":\"Panda: come saltare le righe durante la lettura di un file Excel - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-13T17:02:22+00:00\",\"dateModified\":\"2023-07-13T17:02:22+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con diversi esempi.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Panda: come saltare le righe durante la lettura di un file excel\"}]},{\"@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 saltare le righe durante la lettura di un file Excel - Statorials","description":"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con 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-leggono-le-righe-saltate-di-excel\/","og_locale":"it_IT","og_type":"article","og_title":"Panda: come saltare le righe durante la lettura di un file Excel - Statorials","og_description":"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con diversi esempi.","og_url":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/","og_site_name":"Statorials","article_published_time":"2023-07-13T17:02:22+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/sauter-excel1.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\/i-panda-leggono-le-righe-saltate-di-excel\/","url":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/","name":"Panda: come saltare le righe durante la lettura di un file Excel - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-13T17:02:22+00:00","dateModified":"2023-07-13T17:02:22+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come saltare le righe durante la lettura di un file Excel in un DataFrame panda, con diversi esempi.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/i-panda-leggono-le-righe-saltate-di-excel\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Panda: come saltare le righe durante la lettura di un file excel"}]},{"@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\/4087"}],"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=4087"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/4087\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=4087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=4087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=4087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}