您好,感谢您的时间和考虑.我正在Google Cloud Platform/Datalab中开发一个Jupyter笔记本.我创建了一个Pandas DataFrame,并希望将此DataFrame写入Google云端存储(GCS)和/或BigQuery.我在GCS中有一个存储桶,并通过以下代码创建了以下对象:
import gcp
import gcp.storage as storage
project = gcp.Context.default().project_id
bucket_name = 'steve-temp'
bucket_path = bucket_name
bucket = storage.Bucket(bucket_path)
bucket.exists()
Run Code Online (Sandbox Code Playgroud)
我尝试过基于Google Datalab文档的各种方法,但仍然失败.谢谢
python google-cloud-storage google-cloud-platform google-cloud-datalab
我知道两者都建立在Jupyter noteboooks上,但在云端运行.为什么我们有两个呢?
google-cloud-platform google-cloud-datalab google-colaboratory
我正在寻找设置端到端机器学习管道的最佳方法,并评估数据探索组件选项。
我试图找出谷歌云数据实验室和谷歌云人工智能平台笔记本之间的区别。它们似乎都提供了相似的功能,所以不确定它们为什么都存在,或者一个是否是另一个的新迭代。
如果它们不同,一个比另一个有什么好处?
google-cloud-platform google-cloud-datalab gcp-ai-platform-notebook
我想将Json的压缩gzip上传到Google Storage。
我有以下代码:
import datalab.storage as storage
import gzip
path = prefix + '/orders_newline.json.gz'
storage.Bucket('orders').item(path).write_to(gzip.compress(bytes(create_jsonlines(source)),encoding='utf8'), 'application/json')
Run Code Online (Sandbox Code Playgroud)
该create_jsonlines(source)是返回的Json换行符分隔的功能。
运行这段代码可以得到:
TypeError: string argument without an encoding
Run Code Online (Sandbox Code Playgroud)
在Python文档说,格式是:bytes([source[, encoding[, errors]]])我不知道我把它理解为不存在如何使用它的例子。
我也尝试过
bytes([(create_jsonlines(source))[,encoding='utf8']])
Run Code Online (Sandbox Code Playgroud)
这给出了:
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我正在运行Python 3.5
python google-cloud-storage google-cloud-platform google-cloud-datalab
我正在使用以下代码将具有多个NaN值的 Pandas 数据框插入到 BigQuery 表中。数据帧在云 Datalab 中准备。
import google.datalab.bigquery as bq
bqtable = ('project_name', 'dataset_name', 'table_name')
table = bq.Table(bqtable)
table_schema = bq.Schema.from_data(df)
table.create(schema = table_schema, overwrite = True)
table.insert(df)
Run Code Online (Sandbox Code Playgroud)
由于NaN数据框中的值,我收到以下错误:
RequestException: HTTP request failed: Invalid JSON payload received.
Unexpected token. : "user_id": NaN,
^
Run Code Online (Sandbox Code Playgroud)
我知道这JSON不明白,NaN但我不能只是fillna用来将这些NaN值转换为其他值,因为我需要将这些字段插入nullBigQuery 表中。有没有人有解决方法?
dataframe python-3.x pandas google-bigquery google-cloud-datalab
在至少两种情况下,我曾遇到过这种臭名昭著的“ 等待SSH密钥传播。 ”这句话:
我的问题是-会发生什么并使它花费这么长时间?有没有解决的办法,特别是对于DataLab?
即使没有解决方案,我也想理解为什么如此耗时。
我已经得到了一些笔记本电脑并继续使用DataLab.出于各种原因,我想从我的机器上的本地Jupyter笔记本访问相同的数据.
这个问题提出了一些方法,到目前为止我无法工作.
特别是Gcloud库:
from gcloud import bigquery
client = bigquery.Client()
Run Code Online (Sandbox Code Playgroud)
给我一个堆栈跟踪其最后一行:
ContextualVersionConflict: (protobuf 2.6.1 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('protobuf!=3.0.0.b2.post1,>=3.0.0b2'), set(['gcloud']))
Run Code Online (Sandbox Code Playgroud)
熊猫图书馆看起来很有希望:
df=pd.io.gbq.read_gbq('SELECT CCS_Category_ICD9, Gender, Admit_Month FROM [xxxxxxxx-xxxxx:xxxx_100MB_newform.xxxxxx_100MB_newform]ORDER by CCS_Category_ICD9',
project_id='xxxxxxxx-xxxxx')
Run Code Online (Sandbox Code Playgroud)
还给我一个堆栈跟踪:
IOError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/httplib2-0.9.1.dist-info/METADATA'
Run Code Online (Sandbox Code Playgroud)
也许我在Pandas方法上有一个auth问题,虽然我的浏览器目前正在对该项目进行验证?还是我错过了依赖?
任何建议或指导赞赏..
从本地Jupyter笔记本中访问A BigQuery数据源的最佳方法是什么?
pandas google-bigquery google-cloud-platform google-cloud-datalab
假设我在Google云端存储上有一些存储桶/子目录,此存储桶的地址是:
gs://test-monkeys-example/training_data/cats
Run Code Online (Sandbox Code Playgroud)
在这个猫子目录中,我有一堆猫的图像,所有这些都是jpgs.我如何在python循环中通过cats子目录并打印出其中所有文件的名称?
就像是:
for x in directory('gs://test-monkeys-example/training_data/cats'):
print(x)
Run Code Online (Sandbox Code Playgroud)
显然目录('gs:// test-monkeys-example/training_data/cats')不是如何做到的,只是伪问题 - 我该怎么做?!
python google-cloud-storage google-cloud-platform google-cloud-datalab
是否可以(建议)在Google Cloud Datalab中使用R?怎么样?
我有权访问BigQuery表,可以从BigQuery控制台或gcloud命令行使用它。但是我无法在Datalab中针对它编写基本查询,并得到拒绝访问错误。