Computer Science, asked by afisalady7434, 1 year ago

Write pandas dataframe to a new sheet in existing excel file

Answers

Answered by anshujurriya2003
0
import pandas as pd import numpy as np path = r"C:\Users\fedel\Desktop\excelData\PhD_data.xlsx" x1 = np.random.randn(100, 2) df1 = pd.DataFrame(x1) x2 = np.random.randn(100, 2) df2 = pd.DataFrame(x2) writer = pd.ExcelWriter(path, engine = 'xlsxwriter') df1.to_excel(writer, sheet_name = 'x1') df2.to_excel(writer, sheet_name = 'x2') writer.save() writer.close()


by anshu jurriya IITIAN
Similar questions