'Saving updated df to the same spot in xlsx

I need to somehow save the update I changed in my df to the same xlsx file..

for some reason when I try to use

                    with pd.ExcelWriter(file,
                        engine="openpyxl", mode="a", if_sheet_exists="overlay") 
                        as writer:
                        df.to_excel(writer, sheet_name=f"{sheets[counter]}")
                    logger.info(f"The following changes have been made \n{df}")

It appends to the top left row so this isnt an option

also when trying to append using df.iloc or .replace({x : y}, inplace=True) it only updates on python and not the sheet



Sources

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

Source: Stack Overflow

Solution Source