在Ipython中保存DataFrame to_csv的错误消息

时间:2016-06-19 18:03:22

标签: python pandas anaconda jupyter-console

我在第1课(http://nbviewer.jupyter.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/01%20-%20Lesson.ipynb)之后使用Pandas和Anaconda的Jupyter控制台。

我尝试将DataFrame(dict)导出为CSV文件,这是我的代码,它与第1课中的说明相符:

df.to_csv('births1880.csv',index=False,header=False)

我拔出我的头发,但我不断收到错误消息,我不知道为什么。以下是错误消息:

PermissionError                           Traceback (most recent call last)
<ipython-input-29-cb4a3386d140> in <module>()
----> 1 df.to_csv('births1880.csv',index=False,header=False)

/Applications/anaconda/lib/python3.5/site-packages/pandas/core/frame.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, tupleize_cols, date_format, doublequote, escapechar, decimal, **kwds)
   1342                                      doublequote=doublequote,
   1343                                      escapechar=escapechar, decimal=decimal)
-> 1344         formatter.save()
   1345 
   1346         if path_or_buf is None:

/Applications/anaconda/lib/python3.5/site-packages/pandas/formats/format.py in save(self)
   1524             f = _get_handle(self.path_or_buf, self.mode,
   1525                             encoding=self.encoding,
-> 1526                             compression=self.compression)
   1527             close = True
   1528 

/Applications/anaconda/lib/python3.5/site-packages/pandas/io/common.py in _get_handle(path, mode, encoding, compression)
    422                 f = open(path, mode, encoding=encoding)
    423             else:
--> 424                 f = open(path, mode, errors='replace')
    425         else:
    426             f = open(path, mode)

PermissionError: [Errno 13] Permission denied: 'births1880.csv'

0 个答案:

没有答案