Skip to content

Commit b23910a

Browse files
jrebackmcocdawc
authored andcommitted
DOC: revert gbq doc-strings to be in-line rather than wrapped
1 parent 55c6d52 commit b23910a

File tree

2 files changed

+87
-24
lines changed

2 files changed

+87
-24
lines changed

pandas/core/frame.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
from pandas import compat
7979
from pandas.compat.numpy import function as nv
8080
from pandas.util.decorators import (deprecate_kwarg, Appender,
81-
Substitution, docstring_wrapper)
81+
Substitution)
8282
from pandas.util.validators import validate_bool_kwarg
8383

8484
from pandas.tseries.period import PeriodIndex
@@ -908,7 +908,26 @@ def to_gbq(self, destination_table, project_id, chunksize=10000,
908908
verbose=True, reauth=False, if_exists='fail', private_key=None):
909909
"""Write a DataFrame to a Google BigQuery table.
910910
911-
THIS IS AN EXPERIMENTAL LIBRARY
911+
The main method a user calls to export pandas DataFrame contents to
912+
Google BigQuery table.
913+
914+
Google BigQuery API Client Library v2 for Python is used.
915+
Documentation is available `here
916+
<https://developers.google.com/api-client-library/python/apis/bigquery/v2>`__
917+
918+
Authentication to the Google BigQuery service is via OAuth 2.0.
919+
920+
- If "private_key" is not provided:
921+
922+
By default "application default credentials" are used.
923+
924+
If default application credentials are not found or are restrictive,
925+
user account credentials are used. In this case, you will be asked to
926+
grant permissions for product name 'pandas GBQ'.
927+
928+
- If "private_key" is provided:
929+
930+
Service account credentials will be used to authenticate.
912931
913932
Parameters
914933
----------
@@ -933,8 +952,6 @@ def to_gbq(self, destination_table, project_id, chunksize=10000,
933952
Service account private key in JSON format. Can be file path
934953
or string contents. This is useful for remote server
935954
authentication (eg. jupyter iPython notebook on remote host)
936-
937-
.. versionadded:: 0.17.0
938955
"""
939956

940957
from pandas.io import gbq
@@ -5402,16 +5419,6 @@ def combineMult(self, other):
54025419
_EMPTY_SERIES = Series([])
54035420

54045421

5405-
# patch in the doc-string for to_gbq
5406-
# and bind this method
5407-
def _f():
5408-
from pandas.io.gbq import _try_import
5409-
return _try_import().to_gbq.__doc__
5410-
5411-
5412-
DataFrame.to_gbq = docstring_wrapper(DataFrame.to_gbq, _f)
5413-
5414-
54155422
def _arrays_to_mgr(arrays, arr_names, index, columns, dtype=None):
54165423
"""
54175424
Segregate Series based on type and coerce into matrices.

pandas/io/gbq.py

+66-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
""" Google BigQuery support """
22

3-
from pandas.util.decorators import docstring_wrapper
4-
53

64
def _try_import():
75
# since pandas is a dependency of pandas-gbq
@@ -25,6 +23,72 @@ def _try_import():
2523
def read_gbq(query, project_id=None, index_col=None, col_order=None,
2624
reauth=False, verbose=True, private_key=None, dialect='legacy',
2725
**kwargs):
26+
r"""Load data from Google BigQuery.
27+
28+
The main method a user calls to execute a Query in Google BigQuery
29+
and read results into a pandas DataFrame.
30+
31+
Google BigQuery API Client Library v2 for Python is used.
32+
Documentation is available `here
33+
<https://developers.google.com/api-client-library/python/apis/bigquery/v2>`__
34+
35+
Authentication to the Google BigQuery service is via OAuth 2.0.
36+
37+
- If "private_key" is not provided:
38+
39+
By default "application default credentials" are used.
40+
41+
If default application credentials are not found or are restrictive,
42+
user account credentials are used. In this case, you will be asked to
43+
grant permissions for product name 'pandas GBQ'.
44+
45+
- If "private_key" is provided:
46+
47+
Service account credentials will be used to authenticate.
48+
49+
Parameters
50+
----------
51+
query : str
52+
SQL-Like Query to return data values
53+
project_id : str
54+
Google BigQuery Account project ID.
55+
index_col : str (optional)
56+
Name of result column to use for index in results DataFrame
57+
col_order : list(str) (optional)
58+
List of BigQuery column names in the desired order for results
59+
DataFrame
60+
reauth : boolean (default False)
61+
Force Google BigQuery to reauthenticate the user. This is useful
62+
if multiple accounts are used.
63+
verbose : boolean (default True)
64+
Verbose output
65+
private_key : str (optional)
66+
Service account private key in JSON format. Can be file path
67+
or string contents. This is useful for remote server
68+
authentication (eg. jupyter iPython notebook on remote host)
69+
70+
dialect : {'legacy', 'standard'}, default 'legacy'
71+
'legacy' : Use BigQuery's legacy SQL dialect.
72+
'standard' : Use BigQuery's standard SQL (beta), which is
73+
compliant with the SQL 2011 standard. For more information
74+
see `BigQuery SQL Reference
75+
<https://cloud.google.com/bigquery/sql-reference/>`__
76+
77+
**kwargs : Arbitrary keyword arguments
78+
configuration (dict): query config parameters for job processing.
79+
For example:
80+
81+
configuration = {'query': {'useQueryCache': False}}
82+
83+
For more information see `BigQuery SQL Reference
84+
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`__
85+
86+
Returns
87+
-------
88+
df: DataFrame
89+
DataFrame representing results of query
90+
91+
"""
2892
pandas_gbq = _try_import()
2993
return pandas_gbq.read_gbq(
3094
query, project_id=project_id,
@@ -35,18 +99,10 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
3599
**kwargs)
36100

37101

38-
read_gbq = docstring_wrapper(read_gbq,
39-
lambda: _try_import().read_gbq.__doc__)
40-
41-
42102
def to_gbq(dataframe, destination_table, project_id, chunksize=10000,
43103
verbose=True, reauth=False, if_exists='fail', private_key=None):
44104
pandas_gbq = _try_import()
45105
pandas_gbq.to_gbq(dataframe, destination_table, project_id,
46106
chunksize=chunksize,
47107
verbose=verbose, reauth=reauth,
48108
if_exists=if_exists, private_key=private_key)
49-
50-
51-
to_gbq = docstring_wrapper(to_gbq,
52-
lambda: _try_import().to_gbq.__doc__)

0 commit comments

Comments
 (0)