Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将数据帧保存到Ipython中的\u csv时出错消息_Python_Pandas_Anaconda_Jupyter Console - Fatal编程技术网

将数据帧保存到Ipython中的\u csv时出错消息

将数据帧保存到Ipython中的\u csv时出错消息,python,pandas,anaconda,jupyter-console,Python,Pandas,Anaconda,Jupyter Console,我将学习第1课()关于使用Anaconda的Jupyter控制台的Pandas 我正在尝试将数据帧(dict)导出到CSV文件,下面是我的代码,它与第1课中的说明相匹配: df.to_csv('births1880.csv',index=False,header=False) 我在拔头发,因为我一直收到错误消息,我不知道为什么。以下是错误消息: PermissionError Traceback (most recent call last)

我将学习第1课()关于使用Anaconda的Jupyter控制台的Pandas

我正在尝试将数据帧(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'
PermissionError回溯(最近一次调用)
在()
---->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或buf、sep、na_rep、float格式、列、标题、索引、索引标签、模式、编码、压缩、引号、行终止符、chunksize、tupleize cols、date格式、双引号、转义、十进制、**kwds)
1342双引号=双引号,
1343 escapechar=escapechar,十进制=十进制)
->1344格式化程序。保存()
1345
1346如果路径_或_buf为无:
/save(self)中的Applications/anaconda/lib/python3.5/site-packages/pandas/formats/format.py
1524 f=\u获取\u句柄(self.path\u或\u buf,self.mode,
1525编码=自编码,
->1526压缩=自压缩)
1527关闭=正确
1528
/Applications/anaconda/lib/python3.5/site-packages/pandas/io/common.py in_get_handle(路径、模式、编码、压缩)
422 f=打开(路径、模式、编码=编码)
423其他:
-->424 f=打开(路径、模式、错误='replace')
425其他:
426 f=打开(路径、模式)
PermissionError:[Errno 13]权限被拒绝:“births1880.csv”

如果您试图写入没有权限的目录,请尝试更完整的字符串“~/Documents/births1880.csv”。确切的字符串有点依赖于操作系统和配置。谢谢!我对这个很陌生。我检查了我当前的工作目录,我看到我被指向了运行python的Anaconda目录。我和shell争了起来,想更改我的目录,但它不允许我选择我想要的目录。但是,我可以将我的目录更改为应用程序的父目录。考虑到我至少可以把自己带到那里,那就是我丢弃CSV文件的地方。成功了!现在,我要从这里开始工作。非常感谢。如果您试图写入一个您没有权限的目录,请尝试更完整的字符串“~/Documents/births1880.csv”。确切的字符串有点依赖于操作系统和配置。谢谢!我对这个很陌生。我检查了我当前的工作目录,我看到我被指向了运行python的Anaconda目录。我和shell争了起来,想更改我的目录,但它不允许我选择我想要的目录。但是,我可以将我的目录更改为应用程序的父目录。考虑到我至少可以把自己带到那里,那就是我丢弃CSV文件的地方。成功了!现在,我要从这里开始工作。非常感谢。