I have a dataframe that I want to export to Excel. I'm new to python and pandas so I need some help on this simple task.
df2.to_excel('C:\BT\stack_test3.xlsx')
Error message:
IOError: [Errno 13] Permission denied: 'C:\BT\stack_test3.xlsx'
You path is incorrect, because you have not escaped the slashes it thinks you are trying to write to the root of c: drive use the following:
df2.to_excel(r'C:\BT\stack_test3.xlsx')
The r
makes the path a raw string and means you do not need to escape the slashes
Edit
It seems that there is some error with openpyxl
as using
df2.to_excel(r'C:\BT\stack_test3.xls')
works which uses xlwt
, I don't know enough about those packages so it could be either a permissions problem with openpyxl
which I have not been able to find anything about or a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With