python - 将数据集从 google cloud datalab 导出到 google colab
问题描述
我在我的 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 中旅行。
提前致谢。
解决方案
为了将您的 BigQuery 数据读入 Colab 实例中的 DataFrame,您需要:
- 如果您没有,请使用Cloud Resource Manager创建一个项目;
- 为项目启用计费;
- 启用 BigQuery API,以便您可以与 BigQuery 进行交互;
完成这些步骤后,您可以使用文档中的此代码段。请注意,from google.colab import auth auth.authenticate_user()
验证您访问 BigQuery 的请求。此外,您将使用pd.io.gbq.read_gbq()
来编写查询。
推荐阅读
- javascript - 谁能用打字稿解释<->
- node.js - withCredentials = true 即使在使用 CORS 后也无法正常工作
- java - 无法导入 MultiDexApplication
- python - 蟒蛇 | 拆分字符串并接收两个列表,但最后一个索引中仍然存在分隔符
- javascript - 如何使对象在 x 轴上以随机方向移动,然后保持在该方向上?
- reactjs - 显示异步行为的 componentWillMount 内的调度
- html - bootstrap 4 导航栏的背景颜色问题
- java - 即使应用程序终止,如何在后台使用下载管理器下载多个文件?
- c# - 将列表的每个项目转换为wpf中的字符串
- java - Mockito 没有嘲笑该方法