pandas.read_gbq#

pandas.read_gbq(query, project_id=None, index_col=None, col_order=None, reauth=False, auth_local_webserver=True, dialect=None, location=None, configuration=None, credentials=None, use_bqstorage_api=None, max_results=None, progress_bar_type=None)[源代码]#

从Google BigQuery加载数据。

此函数需要 pandas-gbq package

请参阅 How to authenticate with Google BigQuery 身份验证说明指南。

参数
query应力

类似SQL的查询以返回数据值。

project_id字符串,可选

Google BigQuery帐户项目ID。在环境中可用时可选。

index_col字符串,可选

用于结果DataFrame中的索引的结果列的名称。

col_orderList(Str),可选

按结果DataFrame的所需顺序排列的BigQuery列名列表。

reauth布尔值,默认为False

强制Google BigQuery重新验证用户身份。如果使用多个帐户,这将非常有用。

auth_local_webserver布尔值,默认为True

使用 local webserver flow 而不是 console flow 在获取用户凭据时。

New in version 0.2.0 of pandas-gbq

在 1.5.0 版更改: 缺省值更改为 True 。谷歌已经弃用了 auth_local_webserver = False "out of band" (copy-paste) flow

dialect字符串,默认‘旧版’

注意:在将来的版本中,缺省值将更改为“标准”。

要使用的SQL语法方言。值可以是以下值之一:

'legacy'

使用BigQuery的传统SQL方言。有关更多信息,请参见 BigQuery Legacy SQL Reference

'standard'

使用BigQuery的标准SQL,它与SQL 2011标准兼容。有关更多信息,请参见 BigQuery Standard SQL Reference

location字符串,可选

查询作业应运行的位置。请参阅 BigQuery locations documentation 获取可用位置的列表。该位置必须与查询中使用的任何数据集的位置匹配。

New in version 0.5.0 of pandas-gbq

configurationDICT,可选

查询作业处理的配置参数。例如:

配置={‘Query’:{‘useQueryCache’:False}}

有关更多信息,请参见 BigQuery REST API Reference

credentialsGoogle.auth.redentials.Credentials,可选

访问Google API的凭据。使用此参数覆盖默认凭据,例如使用计算引擎 google.auth.compute_engine.Credentials 或服务帐户 google.oauth2.service_account.Credentials 直接去吧。

New in version 0.8.0 of pandas-gbq

use_bqstorage_api布尔值,默认为False

使用 BigQuery Storage API 快速下载查询结果,但成本增加。要使用此接口,首先 enable it in the Cloud Console 。您还必须拥有 bigquery.readsessions.create 对您要向其开单查询的项目的权限。

此功能需要0.10.0版或更高版本的 pandas-gbq 包裹。它还要求 google-cloud-bigquery-storagefastavro 包裹。

0.25.0 新版功能.

max_results整型,可选

如果设置,则限制要从查询结果中提取的最大行数。

New in version 0.12.0 of pandas-gbq

1.1.0 新版功能.

progress_bar_type可选,字符串

如果设置,则使用 tqdm 库在下载数据时显示进度条。安装 tqdm 包以使用此功能。

的可能值 progress_bar_type 包括:

None

没有进度条。

'tqdm'

使用 tqdm.tqdm() 用于打印进度条的函数 sys.stderr

'tqdm_notebook'

使用 tqdm.tqdm_notebook() 函数将进度条显示为Jupyter笔记本小部件。

'tqdm_gui'

使用 tqdm.tqdm_gui() 函数将进度条显示为图形对话框。

请注意,此功能需要0.12.0版或更高版本的 pandas-gbq 包裹。而且它需要 tqdm 包裹。略有不同于 pandas-gbq ,此处的默认设置为 None

1.0.0 新版功能.

退货
DF:DataFrame

表示查询结果的DataFrame。

参见

pandas_gbq.read_gbq

此函数在pandas-gbq库中。

DataFrame.to_gbq

编写一个DataFrame到Google BigQuery。