Permission error when pandas dataframe is write to xlsx file

user6315578 picture user6315578 · Aug 3, 2017 · Viewed 11.9k times · Source

I get this error while i want to keep my dataframe in excel file which name pandas_simple.xlsx

Below is my error:

enter image description here

This is my code:

import pandas as pd
df = pd.DataFrame({'Car': [101, 20, 350, 20, 15, 320, 454]})
writer = pd.ExcelWriter('pandas_simple.xlsx')
df.to_excel(writer, sheet_name='Sheet1')
writer.save()
writer.close()

Anyone can share some idea to me here?

Answer

Michail N picture Michail N · Aug 3, 2017

You try to write to a folder where you need administration rights. Change:

writer = pd.ExcelWriter("pandas_simple.xlsx")

to:

writer = pd.ExcelWriter("C:\\...\\pandas_simple.xlsx")

with the full path and you will not have a problem.