to_dataframe() 错误时查询 returns 没有结果

to_dataframe() bug when query returns no results

如果有效的 BigQuery 查询 returns 0 行,to_dataframe() 会崩溃。 (顺便说一句,我是 运行 在 Google Cloud Datalab 上)

例如:

q = bq.Query('SELECT * FROM [isb-cgc:tcga_201510_alpha.Somatic_Mutation_calls] WHERE ( Protein_Change="V600E" ) LIMIT 10')
r = q.results()
r.to_dataframe()

产生:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-de55245104c0> in <module>()
----> 1 r.to_dataframe()

/usr/local/lib/python2.7/dist-packages/gcp/bigquery/_table.pyc in to_dataframe(self, start_row, max_rows)
    628     # Need to reorder the dataframe to preserve column ordering
    629     ordered_fields = [field.name for field in self.schema]
--> 630     return df[ordered_fields]
    631 
    632   def to_file(self, destination, format='csv', csv_delimiter=',', csv_header=True):

TypeError: 'NoneType' object has no attribute '__getitem__'

这是已知错误吗?

当然不是已知错误。请记录 Felipe 提到的错误。

欢迎贡献,包括错误报告,当然还有修复! :)