@@ -102,36 +102,48 @@ Dataset operations
102102List datasets for the client's project:
103103
104104.. literalinclude :: snippets.py
105+ :language: python
106+ :dedent: 4
105107 :start-after: [START bigquery_list_datasets]
106108 :end-before: [END bigquery_list_datasets]
107109
108110Create a new dataset for the client's project:
109111
110112.. literalinclude :: snippets.py
113+ :language: python
114+ :dedent: 4
111115 :start-after: [START bigquery_create_dataset]
112116 :end-before: [END bigquery_create_dataset]
113117
114118Refresh metadata for a dataset (to pick up changes made by another client):
115119
116120.. literalinclude :: snippets.py
121+ :language: python
122+ :dedent: 4
117123 :start-after: [START bigquery_get_dataset]
118124 :end-before: [END bigquery_get_dataset]
119125
120126Update a property in a dataset's metadata:
121127
122128.. literalinclude :: snippets.py
129+ :language: python
130+ :dedent: 4
123131 :start-after: [START bigquery_update_dataset_description]
124132 :end-before: [END bigquery_update_dataset_description]
125133
126134Modify user permissions on a dataset:
127135
128136.. literalinclude :: snippets.py
137+ :language: python
138+ :dedent: 4
129139 :start-after: [START bigquery_update_dataset_access]
130140 :end-before: [END bigquery_update_dataset_access]
131141
132142Delete a dataset:
133143
134144.. literalinclude :: snippets.py
145+ :language: python
146+ :dedent: 4
135147 :start-after: [START bigquery_delete_dataset]
136148 :end-before: [END bigquery_delete_dataset]
137149
@@ -147,60 +159,80 @@ Table operations
147159List tables for the dataset:
148160
149161.. literalinclude :: snippets.py
162+ :language: python
163+ :dedent: 4
150164 :start-after: [START bigquery_list_tables]
151165 :end-before: [END bigquery_list_tables]
152166
153167Create a table:
154168
155169.. literalinclude :: snippets.py
170+ :language: python
171+ :dedent: 4
156172 :start-after: [START bigquery_create_table]
157173 :end-before: [END bigquery_create_table]
158174
159175Get a table:
160176
161177.. literalinclude :: snippets.py
178+ :language: python
179+ :dedent: 4
162180 :start-after: [START bigquery_get_table]
163181 :end-before: [END bigquery_get_table]
164182
165183Update a property in a table's metadata:
166184
167185.. literalinclude :: snippets.py
186+ :language: python
187+ :dedent: 4
168188 :start-after: [START bigquery_update_table_description]
169189 :end-before: [END bigquery_update_table_description]
170190
171191Browse selected rows in a table:
172192
173193.. literalinclude :: snippets.py
194+ :language: python
195+ :dedent: 4
174196 :start-after: [START bigquery_browse_table]
175197 :end-before: [END bigquery_browse_table]
176198
177199Insert rows into a table's data:
178200
179201.. literalinclude :: snippets.py
202+ :language: python
203+ :dedent: 4
180204 :start-after: [START bigquery_table_insert_rows]
181205 :end-before: [END bigquery_table_insert_rows]
182206
183207Copy a table:
184208
185209.. literalinclude :: snippets.py
210+ :language: python
211+ :dedent: 4
186212 :start-after: [START bigquery_copy_table]
187213 :end-before: [END bigquery_copy_table]
188214
189215Extract a table to Google Cloud Storage:
190216
191217.. literalinclude :: snippets.py
218+ :language: python
219+ :dedent: 4
192220 :start-after: [START bigquery_extract_table]
193221 :end-before: [END bigquery_extract_table]
194222
195223Delete a table:
196224
197225.. literalinclude :: snippets.py
226+ :language: python
227+ :dedent: 4
198228 :start-after: [START bigquery_delete_table]
199229 :end-before: [END bigquery_delete_table]
200230
201231Upload table data from a file:
202232
203233.. literalinclude :: snippets.py
234+ :language: python
235+ :dedent: 4
204236 :start-after: [START bigquery_load_from_file]
205237 :end-before: [END bigquery_load_from_file]
206238
@@ -213,18 +245,24 @@ See also: `Loading JSON data from Cloud Storage
213245Load a CSV file from Cloud Storage:
214246
215247.. literalinclude :: snippets.py
248+ :language: python
249+ :dedent: 4
216250 :start-after: [START bigquery_load_table_gcs_csv]
217251 :end-before: [END bigquery_load_table_gcs_csv]
218252
219253Load a JSON file from Cloud Storage:
220254
221255.. literalinclude :: snippets.py
256+ :language: python
257+ :dedent: 4
222258 :start-after: [START bigquery_load_table_gcs_json]
223259 :end-before: [END bigquery_load_table_gcs_json]
224260
225261Load a Parquet file from Cloud Storage:
226262
227263.. literalinclude :: snippets.py
264+ :language: python
265+ :dedent: 4
228266 :start-after: [START bigquery_load_table_gcs_parquet]
229267 :end-before: [END bigquery_load_table_gcs_parquet]
230268
@@ -241,33 +279,43 @@ Create a new table, using a customer-managed encryption key from
241279Cloud KMS to encrypt it.
242280
243281.. literalinclude :: snippets.py
282+ :language: python
283+ :dedent: 4
244284 :start-after: [START bigquery_create_table_cmek]
245285 :end-before: [END bigquery_create_table_cmek]
246286
247287Change the key used to encrypt a table.
248288
249289.. literalinclude :: snippets.py
290+ :language: python
291+ :dedent: 4
250292 :start-after: [START bigquery_update_table_cmek]
251293 :end-before: [END bigquery_update_table_cmek]
252294
253295Load a file from Cloud Storage, using a customer-managed encryption key from
254296Cloud KMS for the destination table.
255297
256298.. literalinclude :: snippets.py
299+ :language: python
300+ :dedent: 4
257301 :start-after: [START bigquery_load_table_gcs_json_cmek]
258302 :end-before: [END bigquery_load_table_gcs_json_cmek]
259303
260304Copy a table, using a customer-managed encryption key from Cloud KMS for the
261305destination table.
262306
263307.. literalinclude :: snippets.py
308+ :language: python
309+ :dedent: 4
264310 :start-after: [START bigquery_copy_table_cmek]
265311 :end-before: [END bigquery_copy_table_cmek]
266312
267313Write query results to a table, using a customer-managed encryption key from
268314Cloud KMS for the destination table.
269315
270316.. literalinclude :: snippets.py
317+ :language: python
318+ :dedent: 4
271319 :start-after: [START bigquery_query_destination_table_cmek]
272320 :end-before: [END bigquery_query_destination_table_cmek]
273321
@@ -281,6 +329,8 @@ Querying data
281329Run a query and wait for it to finish:
282330
283331.. literalinclude :: snippets.py
332+ :language: python
333+ :dedent: 4
284334 :start-after: [START bigquery_query]
285335 :end-before: [END bigquery_query]
286336
@@ -289,6 +339,8 @@ Run a dry run query
289339~~~~~~~~~~~~~~~~~~~
290340
291341.. literalinclude :: snippets.py
342+ :language: python
343+ :dedent: 4
292344 :start-after: [START bigquery_query_dry_run]
293345 :end-before: [END bigquery_query_dry_run]
294346
@@ -300,8 +352,10 @@ See BigQuery documentation for more information on
300352`writing query results <https://cloud.google.com/bigquery/docs/writing-results >`_.
301353
302354.. literalinclude :: snippets.py
303- :start-after: [START bigquery_query_destination_table]
304- :end-before: [END bigquery_query_destination_table]
355+ :language: python
356+ :dedent: 4
357+ :start-after: [START bigquery_query_destination_table]
358+ :end-before: [END bigquery_query_destination_table]
305359
306360
307361Run a query using a named query parameter
@@ -311,12 +365,14 @@ See BigQuery documentation for more information on
311365`parameterized queries <https://cloud.google.com/bigquery/docs/parameterized-queries >`_.
312366
313367.. literalinclude :: snippets.py
314- :start-after: [START bigquery_query_params_named]
315- :end-before: [END bigquery_query_params_named]
368+ :language: python
369+ :dedent: 4
370+ :start-after: [START bigquery_query_params_named]
371+ :end-before: [END bigquery_query_params_named]
316372
317373
318374List jobs for a project
319- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
375+ -----------------------
320376
321377Jobs describe actions performed on data in BigQuery tables:
322378
@@ -326,12 +382,14 @@ Jobs describe actions performed on data in BigQuery tables:
326382- Copy a table
327383
328384.. literalinclude :: snippets.py
385+ :language: python
386+ :dedent: 4
329387 :start-after: [START bigquery_list_jobs]
330388 :end-before: [END bigquery_list_jobs]
331389
332390
333391Using BigQuery with Pandas
334- ~~~~~~~~~~~~~~~~~~~~~~~~~~
392+ --------------------------
335393
336394As of version 0.29.0, you can use the
337395:func: `~google.cloud.bigquery.table.RowIterator.to_dataframe ` function to
@@ -353,15 +411,33 @@ Alternatively, you can install the BigQuery python client library with
353411 To retrieve query results as a :class: `pandas.DataFrame `:
354412
355413.. literalinclude :: snippets.py
414+ :language: python
415+ :dedent: 4
356416 :start-after: [START bigquery_query_results_dataframe]
357417 :end-before: [END bigquery_query_results_dataframe]
358418
359419To retrieve table rows as a :class: `pandas.DataFrame `:
360420
361421.. literalinclude :: snippets.py
422+ :language: python
423+ :dedent: 4
362424 :start-after: [START bigquery_list_rows_dataframe]
363425 :end-before: [END bigquery_list_rows_dataframe]
364426
427+ As of version 1.3.0, you can use the
428+ :func: `~google.cloud.bigquery.client.Client.load_table_from_dataframe ` function
429+ to load data from a :class: `pandas.DataFrame ` to a
430+ :class: `~google.cloud.bigquery.table.Table `.
431+
432+ The following example demonstrates how to create a :class: `pandas.DataFrame `
433+ and load it into a new table:
434+
435+ .. literalinclude :: snippets.py
436+ :language: python
437+ :dedent: 4
438+ :start-after: [START bigquery_load_table_dataframe]
439+ :end-before: [END bigquery_load_table_dataframe]
440+
365441Changelog
366442---------
367443
0 commit comments