文章詳情頁
Python使用Excel將數(shù)據(jù)寫入多個sheet
瀏覽:3日期:2022-07-25 13:57:01
將一個列表數(shù)據(jù)寫入output.xlsx的a,b,c……等sheet中
import pandas as pddf1 = pd.DataFrame({’a’:[3,1],’b’:[4,3]}) df2 = df1.copy()with pd.ExcelWriter(’F:python入門數(shù)據(jù)2output.xlsx’) as writer: str1 = [’a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’, ’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’] for i in str1: name = str(i) df1.to_excel(writer, sheet_name= name)writer.save()writer.close()
結(jié)果
此時每個sheet的內(nèi)容都是一樣的。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
標(biāo)簽:
python
相關(guān)文章:
1. 將properties文件的配置設(shè)置為整個Web應(yīng)用的全局變量實現(xiàn)方法2. docker compose idea CreateProcess error=2 系統(tǒng)找不到指定的文件的問題3. 在Vue 中獲取下拉框的文本及選項值操作4. JS中的常見數(shù)組遍歷案例詳解(forEach, map, filter, sort, reduce, every)5. Python語言規(guī)范之Pylint的詳細(xì)用法6. python爬蟲利用代理池更換IP的方法步驟7. Vue+express+Socket實現(xiàn)聊天功能8. python中pandas.read_csv()函數(shù)的深入講解9. SpringBoot集成SSM、Dubbo、Redis、JSP的案例小結(jié)及思路講解10. JS算法題解旋轉(zhuǎn)數(shù)組方法示例
排行榜
