openpyxl

Published by onesixx on

https://xlsxwriter.readthedocs.io/pandas_examples.html

# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('pandas_simple1.xlsx', engine='openpyxl')
# Convert the dataframe to an XlsxWriter Excel object.
df1.to_excel(writer, sheet_name="Sheet1")
df2.to_excel(writer, sheet_name="Sheet2")
# Close the Pandas Excel writer and output the Excel file.
writer.close()
import openpyxl as xl
import seaborn as sns
import pandas as pd

df = sns.load_dataset('iris')

# with pd.ExcelWriter('out.xlsx', engine='openpyxl', mode='a') as writer: 
#     df.to_excel(writer) 

# Create some Pandas dataframes from some data.
df1 = pd.DataFrame({"Data": [11, 12, 13, 14]})
df2 = pd.DataFrame({"Data": [21, 22, 23, 24]})
df3 = pd.DataFrame({"Data": [31, 32, 33, 34]})

# Create a Pandas Excel writer using XlsxWriter as the engine.
writer = pd.ExcelWriter('pandas_simple1.xlsx', engine='openpyxl')


# Convert the dataframe to an XlsxWriter Excel object.
df1.to_excel(writer, sheet_name="Sheet1")
df2.to_excel(writer, sheet_name="Sheet2")
df3.to_excel(writer, sheet_name="Sheet3")
# Close the Pandas Excel writer and output the Excel file.
df.to_excel(writer, sheet_name='shit')

writer.close()
Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x