我正在学习第 1 课(http://nbviewer.jupyter.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/01%20-%20Lesson.ipynb)在 Jupyter 中使用 Pandas来自 Anaconda 的控制台。
我正在尝试将 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'