我正在用colab编写一个python,我想读取存储在我计算机中的csv。下面是我的代码:
df = pd.read_csv('C:\\Users\Alen\Downloads\price.csv',header=1)
错误消息如下所示:
No such file or directory: 'C:\\Users\\Alen\\Downloads\\price.csv'
但是,我确信这个文件就在这个目录中,并且我已经尝试了很多格式来写入这个目录。我如何解决这个问题?
感谢您的帮助:)!
我解决了这个问题!我在spyder上尝试了相同的代码,它可以工作。所以我猜
我有一个Jupyter笔记本,需要在我的本地机器和Google Colab上都能工作。在Google Colab中,一个人必须从他的本地机器上传文件,所以代码应该包括这个选项。
所以,我的问题是检查脚本是否在Google Colab上运行,我正在寻找类似的东西:
if is_local:
data = pd.read_csv('fname')
elif is_colab: # <-- HOW TO DO THIS???
uploaded = files.upload()
# here I choose fnam
我正尝试在google colab笔记本上创建并保存多个csv文件(循环,每次迭代一个文件)。我正在使用 drive.mount('/drive')
f3.to_csv('/drive/My Drive/Colab Notebooks/data/file.csv', index =False) 但很明显,它不起作用。单元格会给我一个文本框来输入我的授权码。有没有办法在循环中保存文件? 为了清楚起见,下面是代码 for k in portkey:
f3 = f2[f2.port_key_anonymised == k]
if f3.shape[0]>0
我需要将Google Colab上的for循环的结果下载到csv文件中,但我一直无法做到。
这是我的for循环:
for num in range(1, 101):
if ( num%2 == 0 and num%6 != 0) or (num%3 ==0 and num%6 != 0):
list = print(num)
笔记本叫做AHW1.ipynb
我试过:
from google.colab import files
files.download("AHW1.csv")
如何将这个for循环的结果下载为csv文件?
我尝试将dataframe (在本例中,我的dataframe是df_fdist)保存到我的google驱动器,所以我像这样运行代码。
from google.colab import files
df_fdist.to_csv('data.csv')
files.download('data.csv')
然而,我得到了这个错误。
OSError: [Errno 107] Transport endpoint is not connected
During handling of the above exception, another exception
我有一个Jupiter笔记本,我已经编写了处理数据的代码。现在我想使用Colab的GPU计算能力,所以我需要从Colab读取和写入我计算机中的本地文件。我不想使用以下命令手动选择文件:
from google.colab import files
uploaded = files.upload()
在中提到的“选择文件”弹出窗口将会出现,我希望这个动作是自动的。让我澄清这一点:
我有下面的代码,我从本地文件中读取数据:
# Reading the csv file and convert it to a dataframe using pandas library
train_set = pd
我在googl colab上传了一个文件,并试图获取该文件的名称
这是我打印upload.keys()时的结果
dict_keys(['SSE.csv', 'SSE_origin.csv'])
我试图访问对象的每个元素。我只找到了这个解决方案。
from google.colab import files
uploaded = files.upload()
for name in uploaded.keys():
print(name)
还有其他像索引这样的解决方案吗?
我用、Google、编写了一个代码,但是在将数据写入csv文件之后,它没有打开。
没有达到我的错误,所有的代码看起来都很完美。
我坚信这个问题之所以会发生,是因为上一次的记录。
'$6.95,Two eggs, bacon or sausage, toast, and our ever-popular hash browns,Homestyle Breakfast,950'
错误:
Row 0 given with size different than 91 (the number of columns in the table).
Error: Row 0 giv
在Google Colab上训练用于对象检测的数据集模型(Darknet)时,我是否需要保持与Colab和互联网的连接?由于训练是在Colab上进行的,并连接到我的驱动器,因此重量文件将保存在我的google驱动器文件夹中。那么,我可以断开我的互联网并退出colab吗? this is the last screen shown when I started my training process on COLAB and now I am waiting for my weight files to be saved in my drive
例如,我正在开发google协作室,我已经将我的gdrive挂载到它上,这样我就可以访问我正在处理的与熊猫有关的csv数据。 # Mount the path to the location of your data
from google.colab import drive
drive.mount('/gdrive') 一切都很好。 但现在,当我将我的colab分享给其他同事时,他们当然无法访问csv文件。那么,我如何共享这些驻留在我的驱动器中的csv呢?或者,除了将数据托管到gdrive中,我和我的同事可以通过panda read_csv访问它们之外,还有其他选择吗?