Google Datalab)如何通过pandas read_csv()读取Google云端存储中存在的多个csv文件? [英] Google Datalab) How to read multiple csv files existing in Google Cloud Storage by pandas read_csv() to?

查看:126
本文介绍了Google Datalab)如何通过pandas read_csv()读取Google云端存储中存在的多个csv文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Datalab 中找到了读取单个csv文件的解决方案:如何将我的csv从google dataLab加载到熊猫数据框?

I found the solution for reading a "single" csv file in a Datalab : How can i load my csv from google dataLab to a pandas data frame?

但我想知道如何在 Datalab 中读取多个csv文件。

But I wonder how I could read "multiple" csv files in Datalab.

我试过的是这样的:

What I tried is like this :

variable_list = ['IBM', 'SPY']
for variable in variable_list:
  file_path = "gs://chois-trader-bucket/data/" + variable + ".csv"
  %%storage read --object file_path --variable variable

但是这个失败了,因为python变量不兼容magic命令。

But this one failed because python variable is not compatible with magic command.

如何有效地处理多个csv文件?

How can I deal with multiple csv files effectively?

推荐答案

您可以使用括号中的 变量

You can use variables enclosed in braces.

e.g) %storage read --object {file_path} --variable variable

这篇关于Google Datalab)如何通过pandas read_csv()读取Google云端存储中存在的多个csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆