将Pandas DataFrame写入XLSX文件时出现权限错误 [英] Permission error when pandas dataframe is write to xlsx file
本文介绍了将Pandas DataFrame写入XLSX文件时出现权限错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将数据框保存在名为pandas_simple.xlsx的excel文件中时出现此错误
I get this error while i want to keep my dataframe in excel file which name pandas_simple.xlsx
以下是我的错误:
这是我的代码:
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?
推荐答案
您尝试写入需要管理权限的文件夹.更改:
You try to write to a folder where you need administration rights. Change:
writer = pd.ExcelWriter("pandas_simple.xlsx")
收件人:
writer = pd.ExcelWriter("C:\\...\\pandas_simple.xlsx")
具有完整路径,您不会有任何问题.
with the full path and you will not have a problem.
这篇关于将Pandas DataFrame写入XLSX文件时出现权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文