@@ -1116,10 +1116,9 @@ def to_dict(self, orient='dict', into=dict):
1116
1116
else :
1117
1117
raise ValueError ("orient '%s' not understood" % orient )
1118
1118
1119
- def to_gbq (
1120
- self , destination_table , project_id , chunksize = 10000 ,
1121
- verbose = True , reauth = False , if_exists = 'fail' , private_key = None ,
1122
- auth_local_webserver = False , table_schema = None ):
1119
+ def to_gbq (self , destination_table , project_id , chunksize = None ,
1120
+ verbose = True , reauth = False , if_exists = 'fail' , private_key = None ,
1121
+ auth_local_webserver = False , table_schema = None ):
1123
1122
"""
1124
1123
Write a DataFrame to a Google BigQuery table.
1125
1124
@@ -1128,57 +1127,61 @@ def to_gbq(
1128
1127
1129
1128
Authentication to the Google BigQuery service is via OAuth 2.0.
1130
1129
1131
- - If "private_key" is not provided:
1130
+ - If ``private_key`` is provided, the library loads the JSON service
1131
+ account credentials and uses those to authenticate.
1132
1132
1133
- By default "application default credentials" are used.
1133
+ - If no ``private_key`` is provided, the library tries `application
1134
+ default credentials`_.
1134
1135
1135
- If default application credentials are not found or are restrictive,
1136
- user account credentials are used. In this case, you will be asked to
1137
- grant permissions for product name 'pandas GBQ'.
1136
+ .. _application default credentials:
1137
+ https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application
1138
1138
1139
- - If "private_key" is provided:
1140
-
1141
- Service account credentials will be used to authenticate.
1139
+ - If application default credentials are not found or cannot be used
1140
+ with BigQuery, the library authenticates with user account
1141
+ credentials. In this case, you will be asked to grant permissions
1142
+ for product name 'pandas GBQ'.
1142
1143
1143
1144
Parameters
1144
1145
----------
1145
- dataframe : DataFrame
1146
- DataFrame to be written to Google BigQuery.
1147
- destination_table : string
1146
+ destination_table : str
1148
1147
Name of table to be written, in the form 'dataset.tablename'.
1149
1148
project_id : str
1150
1149
Google BigQuery Account project ID.
1151
- chunksize : int (default 10000)
1150
+ chunksize : int, optional
1152
1151
Number of rows to be inserted in each chunk from the dataframe.
1153
1152
Set to ``None`` to load the whole dataframe at once.
1154
- verbose : boolean ( default True)
1153
+ verbose : bool, default True
1155
1154
Show percentage complete.
1156
- reauth : boolean ( default False)
1155
+ reauth : bool, default False
1157
1156
Force Google BigQuery to reauthenticate the user. This is useful
1158
1157
if multiple accounts are used.
1159
- if_exists : {'fail', 'replace', 'append'}, default 'fail'
1160
- Behavior when the destination table exists.
1161
- 'fail': If table exists, do nothing.
1162
- 'replace': If table exists, drop it, recreate it, and insert data.
1163
- 'append': If table exists, insert data. Create if does not exist.
1164
- private_key : str (optional)
1158
+ if_exists : str, default 'fail'
1159
+ Behavior when the destination table exists. Value can be one of:
1160
+
1161
+ ``'fail'``
1162
+ If table exists, do nothing.
1163
+ ``'replace'``
1164
+ If table exists, drop it, recreate it, and insert data.
1165
+ ``'append'``
1166
+ If table exists, insert data. Create if does not exist.
1167
+ private_key : str, optional
1165
1168
Service account private key in JSON format. Can be file path
1166
1169
or string contents. This is useful for remote server
1167
1170
authentication (eg. Jupyter/IPython notebook on remote host).
1168
- auth_local_webserver : boolean ( default False)
1169
- Use the [ local webserver flow] instead of the [ console flow]
1171
+ auth_local_webserver : bool, default False
1172
+ Use the ` local webserver flow`_ instead of the ` console flow`_
1170
1173
when getting user credentials.
1171
1174
1172
- .. [local webserver flow]
1175
+ .. _local webserver flow:
1173
1176
http://google-auth-oauthlib.readthedocs.io/en/latest/reference/google_auth_oauthlib.flow.html#google_auth_oauthlib.flow.InstalledAppFlow.run_local_server
1174
- .. [console flow]
1177
+ .. _console flow:
1175
1178
http://google-auth-oauthlib.readthedocs.io/en/latest/reference/google_auth_oauthlib.flow.html#google_auth_oauthlib.flow.InstalledAppFlow.run_console
1176
1179
1177
1180
*New in version 0.2.0 of pandas-gbq*.
1178
- table_schema : list of dicts ( optional)
1181
+ table_schema : list of dicts, optional
1179
1182
List of BigQuery table fields to which according DataFrame
1180
- columns conform to, e.g. `[{'name': 'col1', 'type':
1181
- 'STRING'},...]`. If schema is not provided, it will be
1183
+ columns conform to, e.g. `` [{'name': 'col1', 'type':
1184
+ 'STRING'},...]`` . If schema is not provided, it will be
1182
1185
generated according to dtypes of DataFrame columns. See
1183
1186
BigQuery API documentation on available names of a field.
1184
1187
0 commit comments