-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to_gbq and read_gbq to pandas-gbq 0.5.0 #21628
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,34 +22,26 @@ def _try_import(): | |
|
||
|
||
def read_gbq(query, project_id=None, index_col=None, col_order=None, | ||
reauth=False, verbose=None, private_key=None, dialect='legacy', | ||
**kwargs): | ||
reauth=False, private_key=None, auth_local_webserver=False, | ||
dialect='legacy', location=None, configuration=None, | ||
verbose=None): | ||
""" | ||
Load data from Google BigQuery. | ||
|
||
This function requires the `pandas-gbq package | ||
<https://pandas-gbq.readthedocs.io>`__. | ||
|
||
Authentication to the Google BigQuery service is via OAuth 2.0. | ||
|
||
- If "private_key" is not provided: | ||
|
||
By default "application default credentials" are used. | ||
|
||
If default application credentials are not found or are restrictive, | ||
user account credentials are used. In this case, you will be asked to | ||
grant permissions for product name 'pandas GBQ'. | ||
|
||
- If "private_key" is provided: | ||
|
||
Service account credentials will be used to authenticate. | ||
See the `How to authenticate with Google BigQuery | ||
<https://pandas-gbq.readthedocs.io/en/latest/howto/authentication.html>`__ | ||
guide for authentication instructions. | ||
|
||
Parameters | ||
---------- | ||
query : str | ||
SQL-Like Query to return data values. | ||
project_id : str | ||
Google BigQuery Account project ID. | ||
project_id : str, optional | ||
Google BigQuery Account project ID. Optional when available from | ||
the environment. | ||
index_col : str, optional | ||
Name of result column to use for index in results DataFrame. | ||
col_order : list(str), optional | ||
|
@@ -62,6 +54,16 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None, | |
Service account private key in JSON format. Can be file path | ||
or string contents. This is useful for remote server | ||
authentication (eg. Jupyter/IPython notebook on remote host). | ||
auth_local_webserver : boolean, default False | ||
Use the `local webserver flow`_ instead of the `console flow`_ | ||
when getting user credentials. | ||
|
||
.. _local webserver flow: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think these break linting, need a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding I do not get any lint errors when I run |
||
http://google-auth-oauthlib.readthedocs.io/en/latest/reference/google_auth_oauthlib.flow.html#google_auth_oauthlib.flow.InstalledAppFlow.run_local_server | ||
.. _console flow: | ||
http://google-auth-oauthlib.readthedocs.io/en/latest/reference/google_auth_oauthlib.flow.html#google_auth_oauthlib.flow.InstalledAppFlow.run_console | ||
|
||
*New in version 0.2.0 of pandas-gbq*. | ||
dialect : str, default 'legacy' | ||
SQL syntax dialect to use. Value can be one of: | ||
|
||
|
@@ -74,19 +76,26 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None, | |
compliant with the SQL 2011 standard. For more information | ||
see `BigQuery Standard SQL Reference | ||
<https://cloud.google.com/bigquery/docs/reference/standard-sql/>`__. | ||
verbose : boolean, deprecated | ||
*Deprecated in Pandas-GBQ 0.4.0.* Use the `logging module | ||
to adjust verbosity instead | ||
<https://pandas-gbq.readthedocs.io/en/latest/intro.html#logging>`__. | ||
kwargs : dict | ||
Arbitrary keyword arguments. | ||
configuration (dict): query config parameters for job processing. | ||
location : str, optional | ||
Location where the query job should run. See the `BigQuery locations | ||
documentation | ||
<https://cloud.google.com/bigquery/docs/dataset-locations>`__ for a | ||
list of available locations. The location must match that of any | ||
datasets used in the query. | ||
|
||
*New in version 0.5.0 of pandas-gbq*. | ||
configuration : dict, optional | ||
Query config parameters for job processing. | ||
For example: | ||
|
||
configuration = {'query': {'useQueryCache': False}} | ||
|
||
For more information see `BigQuery SQL Reference | ||
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`__ | ||
For more information see `BigQuery REST API Reference | ||
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`__. | ||
verbose : None, deprecated | ||
Deprecated in Pandas-GBQ 0.4.0. Use the `logging module | ||
to adjust verbosity instead | ||
<https://pandas-gbq.readthedocs.io/en/latest/intro.html#logging>`__. | ||
|
||
Returns | ||
------- | ||
|
@@ -100,20 +109,21 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None, | |
""" | ||
pandas_gbq = _try_import() | ||
return pandas_gbq.read_gbq( | ||
query, project_id=project_id, | ||
index_col=index_col, col_order=col_order, | ||
reauth=reauth, verbose=verbose, | ||
private_key=private_key, | ||
dialect=dialect, | ||
**kwargs) | ||
query, project_id=project_id, index_col=index_col, | ||
col_order=col_order, reauth=reauth, verbose=verbose, | ||
private_key=private_key, auth_local_webserver=auth_local_webserver, | ||
dialect=dialect, location=location, configuration=configuration) | ||
|
||
|
||
def to_gbq(dataframe, destination_table, project_id, chunksize=None, | ||
def to_gbq(dataframe, destination_table, project_id=None, chunksize=None, | ||
verbose=None, reauth=False, if_exists='fail', private_key=None, | ||
auth_local_webserver=False, table_schema=None): | ||
auth_local_webserver=False, table_schema=None, location=None, | ||
progress_bar=True): | ||
pandas_gbq = _try_import() | ||
return pandas_gbq.to_gbq( | ||
dataframe, destination_table, project_id, chunksize=chunksize, | ||
verbose=verbose, reauth=reauth, if_exists=if_exists, | ||
private_key=private_key, auth_local_webserver=auth_local_webserver, | ||
table_schema=table_schema) | ||
dataframe, destination_table, project_id=project_id, | ||
chunksize=chunksize, verbose=verbose, reauth=reauth, | ||
if_exists=if_exists, private_key=private_key, | ||
auth_local_webserver=auth_local_webserver, | ||
table_schema=table_schema, location=location, | ||
progress_bar=progress_bar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think needs to be single backticks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two backticks is code font in Sphinx RST, which is what I want.