【发布时间】:2016-02-26 16:29:39
【问题描述】:
您好,我在 datalab 上使用 ipython 笔记本时遇到问题。
我想将表的结果写入 bigQuery 表,但它不起作用,有人说要使用 insert_data(dataframe) 函数,但它没有填充我的表。 为了简化问题,我尝试读取一个表并将其写入刚刚创建的表(具有相同的模式),但它不起作用。谁能告诉我哪里错了?
import gcp
import gcp.bigquery as bq
#read the data
df = bq.Query('SELECT 1 as a, 2 as b FROM [publicdata:samples.wikipedia] LIMIT 3').to_dataframe()
#creation of a dataset and extraction of the schema
dataset = bq.DataSet('prova1')
dataset.create(friendly_name='aaa', description='bbb')
schema = bq.Schema.from_dataframe(df)
#creation of the table
temptable = bq.Table('prova1.prova2').create(schema=schema, overwrite=True)
#I try to put the same data into the temptable just created
temptable.insert_data(df)
【问题讨论】:
标签: google-bigquery google-cloud-datalab