通过Google Colab将文件保存到Google驱动器时出错

connor449

我正在尝试从colab笔记本中将文件保存到我的Google云端硬盘中,但始终出现相同的错误。我已经挂载了驱动器。当我致电pwd时,我知道了,这似乎是正确的:

/content/drive/My Drive/

这是示例代码和读出的内容:

from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
print(df)
df.to_csv('test.csv')

         A   B   C   D
    0   38  28  18  74
    1   36  54  84  13
    2    2   1  55  42
    3   69  20  15  40
    4   83  58  81  76
    ..  ..  ..  ..  ..
    95  92  65   3  50
    96  25  15  82  84
    97  60  24  29  10
    98  13  26  94  25
    99  46  36  91  24

    [100 rows x 4 columns]
    ---------------------------------------------------------------------------
    OSError                                   Traceback (most recent call last)
    <ipython-input-10-d5c5784f87b6> in <module>()
          4 df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
          5 print(df)
    ----> 6 df.to_csv('test.csv')

    2 frames
    /usr/local/lib/python3.6/dist-packages/pandas/io/common.py in _get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text)
        397         if encoding:
        398             # Encoding
    --> 399             f = open(path_or_buf, mode, encoding=encoding, newline="")
        400         elif is_text:
        401             # No explicit encoding

    OSError: [Errno 30] Read-only file system: 'test.csv'





广晃

要保存到Google驱动器,应添加安装路径:

from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
print(df)
df.to_csv('/content/drive/My Drive/test.csv')

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如果我断开连接,Google Colab是否会保持运行单元以将文件保存到已安装的驱动器中?

使用Google Colab时如何将文件写入本地驱动器?

运行示例代码以将文件上传到Google驱动器时出错

Google colab驱动器空间减少,即使我将数据保存在Google驱动器中

使用GCP后端访问Google Colab中的驱动器时出错

从本地驱动器读取文件到 google colab

如何将文件从colab或云存储复制到Google驱动器?

尝试将我的 google 工作表以 pdf 格式保存到我的驱动器文件夹时出现问题

通过python禁用Google驱动器文件的下载选项

在 google colab 中安装驱动器

如何通过REST API将文件上传到我自己的Google驱动器

通过php脚本将文件匿名上传到google驱动器

使用应用程序脚本UrlFetchApp将IP摄像机视频保存到Google驱动器

我正在尝试将所有pdf文件下载到Google驱动器中,但未能保存每个位于google驱动器中的pdf文件

尝试将google驱动器添加为文件系统时,“不支持驱动程序[google]。”,“例外”:“ InvalidArgumentException”

如何从Google colab打开和处理存储在Google驱动器中的文件?

Google Colab错误,无法使用Google驱动器中的文件

创建Google驱动器文件时出现FileNotFoundException

如何使用使用Python的驱动器API将文件上传到Google驱动器?

Google Colab:如何从我的Google驱动器读取数据?

从Java将本地文件上传到Google驱动器

将.ogg blob转换为Google驱动器文件

使用beautifulsoup将文件下载到Google驱动器

通过使用Google文档在Web视图中显示(存储在Google驱动器中的)PDF文件

在colab笔记本中的Google驱动器中定义文件的路径

删除Google驱动器usig colab上具有匹配目录名称的zip文件

使用Colab笔记本获取Google驱动器中文件的共享链接

尝试使用python访问“ Google驱动器”时出错(Google quickstart.py源代码)

从另一个驱动器帐户将数据集导入google colab