{"id":972,"date":"2023-07-28T03:32:22","date_gmt":"2023-07-28T03:32:22","guid":{"rendered":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/"},"modified":"2023-07-28T03:32:22","modified_gmt":"2023-07-28T03:32:22","slug":"scrivere-diversi-fogli-excel-di-panda","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/","title":{"rendered":"Come scrivere pandas dataframes su pi\u00f9 fogli excel"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Spesso potresti avere pi\u00f9 DataFrames Panda che desideri scrivere su pi\u00f9 fogli Excel all&#8217;interno della stessa cartella di lavoro.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Fortunatamente, questo pu\u00f2 essere fatto utilizzando la funzione <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.ExcelWriter.html\" target=\"_blank\" rel=\"noopener noreferrer\">ExcelWriter()<\/a> di panda. Per utilizzare questa funzionalit\u00e0, devi prima assicurarti che <strong>xlsxwriter<\/strong> sia installato:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>pip install xlsxwriter<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Devi anche assicurarti <strong>che xlwt<\/strong> sia installato:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong>pip install xlwt<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Una volta installati, puoi scrivere facilmente pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> pandas <span style=\"color: #107d3f;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#create three DataFrames\n<\/span>df1 = pd.DataFrame({'dataset': ['A', 'B', 'C', 'D', 'E']})\ndf2 = pd.DataFrame({'dataset': [13, 15, 15, 17, 22, 24, 29, 30]})\ndf3 = pd.DataFrame({'dataset': [3, 6, 6]})\n\n<span style=\"color: #008080;\">#create a Pandas Excel writer using XlsxWriter as the engine\n<\/span>writer = pd. <span style=\"color: #3366ff;\">ExcelWriter<\/span> (' <span style=\"color: #008000;\">dataframes.xlsx<\/span> ', engine=' <span style=\"color: #008000;\">xlsxwriter<\/span> ')\n\n#write each DataFrame to a specific sheet\ndf1. <span style=\"color: #3366ff;\">to_excel<\/span> (writer, sheet_name=' <span style=\"color: #008000;\">first dataset<\/span> ')\ndf2. <span style=\"color: #3366ff;\">to_excel<\/span> (writer, sheet_name=' <span style=\"color: #008000;\">second dataset<\/span> ')\ndf3. <span style=\"color: #3366ff;\">to_excel<\/span> (writer, sheet_name=' <span style=\"color: #008000;\">third dataset<\/span> ')\n\n<span style=\"color: #008080;\">#close the Pandas Excel writer and output the Excel file\n<\/span>writer.save()<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">La cartella di lavoro Excel risultante avr\u00e0 ciascuno dei DataFrames panda archiviati in un foglio separato:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Il primo DataFrame:<\/strong><\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10165 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pdmultipleexcel1.png\" alt=\"Panda pi\u00f9 DataFrames su pi\u00f9 fogli Excel\" width=\"386\" height=\"404\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Il secondo DataFrame:<\/strong><\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10166 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pdmultipleexcel2.png\" alt=\"I panda esportano in pi\u00f9 fogli Excel\" width=\"383\" height=\"405\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\"><strong>Il terzo DataFrame:<\/strong><\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-10167 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pdmultipleexcel3.png\" alt=\"panda pi\u00f9 fogli di calcolo Excel\" width=\"382\" height=\"394\" srcset=\"\" sizes=\"\"><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/it\/combinare-piu-fogli-excel-di-panda\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come combinare pi\u00f9 fogli Excel in Pandas<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/i-panda-leggono-excel\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come leggere file Excel con Panda<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/i-panda-leggono-csv\/\" target=\"_blank\" rel=\"noopener noreferrer\">Come leggere file CSV con Pandas<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spesso potresti avere pi\u00f9 DataFrames Panda che desideri scrivere su pi\u00f9 fogli Excel all&#8217;interno della stessa cartella di lavoro. Fortunatamente, questo pu\u00f2 essere fatto utilizzando la funzione ExcelWriter() di panda. Per utilizzare questa funzionalit\u00e0, devi prima assicurarti che xlsxwriter sia installato: pip install xlsxwriter Devi anche assicurarti che xlwt sia installato: pip install xlwt Una [&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 scrivere Pandas DataFrames su pi\u00f9 fogli Excel<\/title>\n<meta name=\"description\" content=\"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.\" \/>\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\/scrivere-diversi-fogli-excel-di-panda\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come scrivere Pandas DataFrames su pi\u00f9 fogli Excel\" \/>\n<meta property=\"og:description\" content=\"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-28T03:32:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pdmultipleexcel1.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=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/\",\"url\":\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/\",\"name\":\"Come scrivere Pandas DataFrames su pi\u00f9 fogli Excel\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-28T03:32:22+00:00\",\"dateModified\":\"2023-07-28T03:32:22+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come scrivere pandas dataframes su pi\u00f9 fogli 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":"Come scrivere Pandas DataFrames su pi\u00f9 fogli Excel","description":"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.","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\/scrivere-diversi-fogli-excel-di-panda\/","og_locale":"it_IT","og_type":"article","og_title":"Come scrivere Pandas DataFrames su pi\u00f9 fogli Excel","og_description":"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.","og_url":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/","og_site_name":"Statorials","article_published_time":"2023-07-28T03:32:22+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/pdmultipleexcel1.png"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/","url":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/","name":"Come scrivere Pandas DataFrames su pi\u00f9 fogli Excel","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-28T03:32:22+00:00","dateModified":"2023-07-28T03:32:22+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Una semplice spiegazione su come scrivere pi\u00f9 DataFrames panda su pi\u00f9 fogli Excel.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/scrivere-diversi-fogli-excel-di-panda\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come scrivere pandas dataframes su pi\u00f9 fogli 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\/972"}],"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=972"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/972\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}