【问题标题】:Exporting a dataset from google cloud datalab to google colab将数据集从 google cloud datalab 导出到 google colab
【发布时间】:2021-06-07 16:37:57
【问题描述】:

我在我的 Google Cloud 数据实验室中创建了一个数据集,我想在 Google Colab 中继续处理它(使用 Python)。我不知道应该如何将我的数据集导出到 Google Colab(或 Jupyter)。你能帮我解决一下吗?

这是我在 Google Datalab 中的数据集:

%sql --module afewrecords
Select pickup_datetime, dropoff_datetime, pickup_longitude,
pickup_latitude, dropoff_longitude, dropoff_latitude, passenger_count,
trip_distance, tolls_amount, fare_amount, total_amount
 
From [nyc-tlc:yellow.trips] LIMIT 10

trips = bq.Query(afewrecords).to_dataframe()
trips

我想在 Google Colab 中旅行。

提前致谢。

【问题讨论】:

  • 您是否在 Datalab Notebook 实例中从 BigQuery 访问数据?
  • @AlexandreMoraes 是的

标签: python google-cloud-platform jupyter-notebook google-colaboratory data-mining


【解决方案1】:

为了将 BigQuery 数据读入 Colab 实例中的 DataFrame,您需要,

  1. 如果没有Cloud Resource Manager,请创建一个项目;
  2. Enable billing 代表项目;
  3. 启用 BigQuery API,以便您可以与 BigQuery 进行交互;

完成这些步骤后,您可以使用文档中的this snippet。请注意,from google.colab import auth auth.authenticate_user() 对您访问 BigQuery 的请求进行身份验证。此外,您将使用pd.io.gbq.read_gbq() 来编写您的查询。

【讨论】:

    猜你喜欢
    • 2020-06-22
    • 2017-12-05
    • 2021-01-12
    • 1970-01-01
    • 1970-01-01
    • 2017-11-13
    • 2016-08-25
    • 1970-01-01
    • 2019-05-22
    相关资源
    最近更新 更多