1

如果有效的 BigQuery 查询返回 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__'

这是一个已知的错误?

4

1 回答 1

1

当然不是已知的错误。请按照 Felipe 所述记录错误。

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

于 2015-11-13T03:26:26.243 回答