简体   繁体   English

在google colab中将csv读取到sframe

[英]Read csv to sframe in google colab

I have created a new notebook of python 2 on google-colaboratory and installed sframe(!pip install sframe) but I'm unable to read the CSV file in sframe. 我已经在google-colaboratory上创建了一个新的python 2笔记本,并安装了sframe(!pip install sframe),但是无法读取sframe中的CSV文件。 Any help? 有什么帮助吗?

To read a CSV file in a SFrame, you need to download either turicreate module or GraphLab create module. 要在SFrame中读取CSV文件,您需要下载turicreate模块或GraphLab create模块。

Firstly, you need to import data into colab. 首先,您需要将数据导入到colab中。 So you need to recognize how are you accessing your file: local storage or google drive. 因此,您需要了解如何访问文件:本地存储或Google驱动器。 You can use this link to achieve this: Import data into Google Colaboratory . 您可以使用此链接来实现此目的:将数据导入Google Colaboratory

For downloading the turicreate module in google-colaboratory, do the following steps: 要在google-colaboratory中下载turicreate模块,请执行以下步骤:

1) Install turicreate module using pip in colab. 1)在colab中使用pip安装turicreate模块。

        !pip install turicreate

2) Import the turicreate module. 2)导入turicreate模块。

        import turicreate

3) Use the turicreate.SFrame.read_csv function to import the CSV file into the sframe. 3)使用turicreate.SFrame.read_csv函数将CSV文件导入到sframe中。 Assume that the content of the CSV file is stored as 'file.csv' and the name of the SFrame is 'sf' , use the code below to read the CSV data into a SFrame. 假设CSV文件的内容存储为'file.csv',SFrame的名称为'sf' ,请使用下面的代码将CSV数据读取到SFrame中。

        sf = turicreate.SFrame.read_csv('file.csv')

That's it !!! 而已 !!! You can also do the same with Graphlab create. 您也可以使用Graphlab create进行相同的操作。

Refer to the API documentations over here: 请参阅此处的API文档:

https://apple.github.io/turicreate/docs/api/generated/turicreate.SFrame.read_csv.html#turicreate.SFrame.read_csv https://apple.github.io/turicreate/docs/api/generated/turicreate.SFrame.read_csv.html#turicreate.SFrame.read_csv

https://turi.com/products/create/docs/generated/graphlab.SFrame.read_csv.html https://turi.com/products/create/docs/generated/graphlab.SFrame.read_csv.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM