Cheen
Cheen

Reputation: 86

Panda's ExcelWriter append mode not working

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.

Upvotes: 2

Views: 6380

Answers (1)

Rami Alloush
Rami Alloush

Reputation: 2626

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

Upvotes: 1

Related Questions