2

I don't understand why mode='a' or even mode='w' is not working. My code is :

file = "Data_Complet.xlsx"
df1 = pd.read_excel(file, encoding='utf-8')
df_transfo = DataFrame(df1, columns = ['DATE','Nb'])
print(df_transfo)
with ExcelWriter(path="Data_Complet.xlsx", mode='a') as writer:
    df_transfo.to_excel(writer)

The result is:

TypeError: init() got an unexpected keyword argument 'mode'.

I am using Spyder.

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
Cheen
  • 86
  • 3
  • 12
  • 1
    i can't replicate your error, what is your pandas version? And have you tried this? https://stackoverflow.com/questions/38074678/append-existing-excel-sheet-with-new-dataframe-using-python-pandas – Dan Oct 25 '19 at 10:20
  • 1
    check with pandas version, mode argument is in pandas from 0.24.0 version afterward – qaiser Oct 25 '19 at 10:25
  • That's right, my version is 0.21, thank you. – Cheen Oct 25 '19 at 11:45

1 Answers1

1

I keep coming to this question and forget what I did! So, I'm adding the code for it.

As stated in the comments, you need to have pandas version greater than 0.24.0. Just run

pip install --upgrade pandas
Rami Alloush
  • 2,308
  • 2
  • 27
  • 33