1
我正在使用Google Cloud Datalab,我想將Pandas數據框導出爲新的BigQuery表格。我試圖關注Cloud Datalab附帶的在線幫助筆記本,儘管我可以看到沒有導出到BigQuery的示例,但僅限於Google雲端存儲。如何將數據框從Cloud Datalab導出到BigQuery表中?
無論如何,我可以計算出如何使用正確的模式在BigQuery中創建表,但是我無法弄清楚如何將實際數據放入表中!
這是我現在得到:
dataset = bq.DataSet('calculations')
dataset.create(friendly_name='blah',
description='blah blah')
print 'Dataset exists', dataset.exists()
# Create the schema for the table we're about to create.
schema = bq.Schema.from_dataframe(measures[0]['data'])
print schema
print len(measures[0]['data'])
# Create a table for our results.
temptable = bq.Table('calculations.test').create(schema=schema,
overwrite=True)
# How to export the actual data to the table?
所以這個輸出:
True
[{'type': 'STRING', 'name': u'id'}, {'type': 'STRING', 'name': ...
8173
表明我的數據幀有8173行。
如果我去BigQuery,我發現表格已經創建了正確的模式,但它沒有數據。
我該如何實際導出數據?
如果這是不可能的,那麼我可以導出到雲存儲,而不是我已經嘗試過,並有同樣的問題。我寧願導出到BigQuery。