[Python] Writing to Excel Sheet using Pandas

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to update values in an excel sheet using Pandas but the changes overwrites the whole file instead of just a value in in a sheet.

    sheet_1 = pd.read_excel(r"Documents\TestPage.xlsx", 0)
    sheet_1.loc[0, 'Test1'] = 10
    sheet_1.to_excel("Documents\TestPage.xlsx", sheet_name= 'sheet_1')


    My code intends to change only Test1 value but instead it overwrites the entire new file losing other pages. I noticed that others facing similar issues but I could figure out looking at the answer.

    Appreciate your help and guidance.

    Cheer

    Continue reading...

Compartilhe esta Página