'Append data at the end of excel sheet using pandas

I am new to this and i know this question is posted many times but the problem i am facing for this is new and i cannot find the solution to it.

Okay the actual code is:

 import pandas as pd 
 from openpyxl import load_workbook 
 ExcelWorkbook = load_workbook(r'path')
 df1= pd.read_excel(r'path',sheet_name="MASTER",engine = 'openpyxl') 

 writer=pd.ExcelWriter(df1) 
 writer = pd.ExcelWriter(r'path',sheet_name="MASTER", engine = 'openpyxl') 
 writer.book = ExcelWorkbook

 df2= pd.read_excel(r'path',sheet_name="JAN-22",engine='openpyxl', usecols="B:BQ") 
 df3= pd.read_excel(r'path',engine='openpyxl', usecols="B:BM") 
 df4= pd.read_excel(r'path',engine='openpyxl', usecols="B:BP") 
 df5= pd.read_excel(r'path',engine='openpyxl', usecols="B:BN") 
 df6= pd.read_excel(r'path',engine='openpyxl', usecols="B:BP")

 all_df_list = [df1,df2,df3,df4,df5,df6]
 appended_df = pd.concat(all_df_list)

 max_row=df1.shape[0]
 appended_df.to_excel(writer, startrow=max_row+1, index=None ,header =None)

 writer.save()
 writer.close()

So the problem is .... the data from df2 to df6 is getting appended into a new sheet in my master file df1 after the max number of rows leaving it all empty.

What i want -

//df1 - master sheet
   a b c 
   1 4 5
   2 4 2
(appended data)

What i got from the code i wrote is -

//df1 - new sheet 
    a b c


 (appended data) 

Please help me to get it all appended in the same master file. Thanks in advance !!



Solution 1:[1]

to_excel() takes an optional sheet name/index as a parameter. So use a specific sheet name like:

appended_df.to_excel(writer, sheet_name='Master')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 s0mbre