Skip to content

Commit f58a438

Browse files
committed
Merge pull request #5241 from jorisvandenbossche/docs-gbq-fixes2
DOC: fix building of gbq docs
2 parents d731229 + 7145503 commit f58a438

File tree

3 files changed

+61
-59
lines changed

3 files changed

+61
-59
lines changed

doc/source/v0.13.0.txt

+19-19
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ Experimental
651651
- ``pandas.io.gbq`` provides a simple way to extract from, and load data into,
652652
Google's BigQuery Data Sets by way of pandas DataFrames. BigQuery is a high
653653
performance SQL-like database service, useful for performing ad-hoc queries
654-
against extremely large datasets. :ref:`See the docs<io.gbq>`
654+
against extremely large datasets. :ref:`See the docs <io.bigquery>`
655655

656656
.. code-block:: python
657657

@@ -684,24 +684,24 @@ Experimental
684684
df3 = pandas.concat([df2.min(), df2.mean(), df2.max()],
685685
axis=1,keys=["Min Tem", "Mean Temp", "Max Temp"])
686686

687-
The resulting dataframe is:
688-
689-
```
690-
Min Tem Mean Temp Max Temp
691-
MONTH
692-
1 -53.336667 39.827892 89.770968
693-
2 -49.837500 43.685219 93.437932
694-
3 -77.926087 48.708355 96.099998
695-
4 -82.892858 55.070087 97.317240
696-
5 -92.378261 61.428117 102.042856
697-
6 -77.703334 65.858888 102.900000
698-
7 -87.821428 68.169663 106.510714
699-
8 -89.431999 68.614215 105.500000
700-
9 -86.611112 63.436935 107.142856
701-
10 -78.209677 56.880838 92.103333
702-
11 -50.125000 48.861228 94.996428
703-
12 -50.332258 42.286879 94.396774
704-
```
687+
The resulting dataframe is::
688+
689+
> df3
690+
Min Tem Mean Temp Max Temp
691+
MONTH
692+
1 -53.336667 39.827892 89.770968
693+
2 -49.837500 43.685219 93.437932
694+
3 -77.926087 48.708355 96.099998
695+
4 -82.892858 55.070087 97.317240
696+
5 -92.378261 61.428117 102.042856
697+
6 -77.703334 65.858888 102.900000
698+
7 -87.821428 68.169663 106.510714
699+
8 -89.431999 68.614215 105.500000
700+
9 -86.611112 63.436935 107.142856
701+
10 -78.209677 56.880838 92.103333
702+
11 -50.125000 48.861228 94.996428
703+
12 -50.332258 42.286879 94.396774
704+
705705
.. warning::
706706

707707
To use this module, you will need a BigQuery account. See

pandas/core/frame.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -672,34 +672,34 @@ def to_dict(self, outtype='dict'):
672672
raise ValueError("outtype %s not understood" % outtype)
673673

674674
def to_gbq(self, destination_table, schema=None, col_order=None, if_exists='fail', **kwargs):
675-
"""
676-
Write a DataFrame to a Google BigQuery table. If the table exists,
677-
the DataFrame will be appended. If not, a new table will be created,
678-
in which case the schema will have to be specified. By default,
675+
"""Write a DataFrame to a Google BigQuery table.
676+
677+
If the table exists, the DataFrame will be appended. If not, a new table
678+
will be created, in which case the schema will have to be specified. By default,
679679
rows will be written in the order they appear in the DataFrame, though
680680
the user may specify an alternative order.
681681
682682
Parameters
683683
---------------
684-
destination_table: string
684+
destination_table : string
685685
name of table to be written, in the form 'dataset.tablename'
686686
schema : sequence (optional)
687687
list of column types in order for data to be inserted, e.g. ['INTEGER', 'TIMESTAMP', 'BOOLEAN']
688-
col_order: sequence (optional)
688+
col_order : sequence (optional)
689689
order which columns are to be inserted, e.g. ['primary_key', 'birthday', 'username']
690-
if_exists: {'fail', 'replace', 'append'} (optional)
691-
fail: If table exists, do nothing.
692-
replace: If table exists, drop it, recreate it, and insert data.
693-
append: If table exists, insert data. Create if does not exist.
690+
if_exists : {'fail', 'replace', 'append'} (optional)
691+
- fail: If table exists, do nothing.
692+
- replace: If table exists, drop it, recreate it, and insert data.
693+
- append: If table exists, insert data. Create if does not exist.
694694
kwargs are passed to the Client constructor
695695
696-
Raises:
696+
Raises
697697
------
698-
SchemaMissing:
698+
SchemaMissing :
699699
Raised if the 'if_exists' parameter is set to 'replace', but no schema is specified
700-
TableExists:
700+
TableExists :
701701
Raised if the specified 'destination_table' exists but the 'if_exists' parameter is set to 'fail' (the default)
702-
InvalidSchema:
702+
InvalidSchema :
703703
Raised if the 'schema' parameter does not match the provided DataFrame
704704
"""
705705

pandas/io/gbq.py

+28-26
Original file line numberDiff line numberDiff line change
@@ -316,36 +316,36 @@ def _parse_data(client, job, index_col=None, col_order=None):
316316
return final_df
317317

318318
def to_gbq(dataframe, destination_table, schema=None, col_order=None, if_exists='fail', **kwargs):
319-
"""
320-
Write a DataFrame to a Google BigQuery table. If the table exists,
321-
the DataFrame will be appended. If not, a new table will be created,
322-
in which case the schema will have to be specified. By default,
319+
"""Write a DataFrame to a Google BigQuery table.
320+
321+
If the table exists, the DataFrame will be appended. If not, a new table
322+
will be created, in which case the schema will have to be specified. By default,
323323
rows will be written in the order they appear in the DataFrame, though
324324
the user may specify an alternative order.
325325
326326
Parameters
327-
---------------
328-
dataframe: DataFrame
327+
----------
328+
dataframe : DataFrame
329329
DataFrame to be written
330-
destination_table: string
330+
destination_table : string
331331
name of table to be written, in the form 'dataset.tablename'
332332
schema : sequence (optional)
333333
list of column types in order for data to be inserted, e.g. ['INTEGER', 'TIMESTAMP', 'BOOLEAN']
334-
col_order: sequence (optional)
334+
col_order : sequence (optional)
335335
order which columns are to be inserted, e.g. ['primary_key', 'birthday', 'username']
336-
if_exists: {'fail', 'replace', 'append'} (optional)
337-
fail: If table exists, do nothing.
338-
replace: If table exists, drop it, recreate it, and insert data.
339-
append: If table exists, insert data. Create if does not exist.
336+
if_exists : {'fail', 'replace', 'append'} (optional)
337+
- fail: If table exists, do nothing.
338+
- replace: If table exists, drop it, recreate it, and insert data.
339+
- append: If table exists, insert data. Create if does not exist.
340340
kwargs are passed to the Client constructor
341341
342-
Raises:
342+
Raises
343343
------
344-
SchemaMissing:
344+
SchemaMissing :
345345
Raised if the 'if_exists' parameter is set to 'replace', but no schema is specified
346-
TableExists:
346+
TableExists :
347347
Raised if the specified 'destination_table' exists but the 'if_exists' parameter is set to 'fail' (the default)
348-
InvalidSchema:
348+
InvalidSchema :
349349
Raised if the 'schema' parameter does not match the provided DataFrame
350350
"""
351351

@@ -416,35 +416,37 @@ def to_gbq(dataframe, destination_table, schema=None, col_order=None, if_exists=
416416
job = client.Load(table_reference, csv_file.name, schema=schema, **opts)
417417

418418
def read_gbq(query, project_id = None, destination_table = None, index_col=None, col_order=None, **kwargs):
419-
"""
419+
"""Load data from Google BigQuery.
420+
420421
The main method a user calls to load data from Google BigQuery into a pandas DataFrame.
421422
This is a simple wrapper for Google's bq.py and bigquery_client.py, which we use
422423
to get the source data. Because of this, this script respects the user's bq settings
423424
file, '~/.bigqueryrc', if it exists. Such a file can be generated using 'bq init'. Further,
424-
additional parameters for the query can be specified as either **kwds in the command,
425+
additional parameters for the query can be specified as either ``**kwds`` in the command,
425426
or using FLAGS provided in the 'gflags' module. Particular options can be found in
426427
bigquery_client.py.
427428
428429
Parameters
429430
----------
430-
query: str
431+
query : str
431432
SQL-Like Query to return data values
432-
project_id: str (optional)
433+
project_id : str (optional)
433434
Google BigQuery Account project ID. Optional, since it may be
434435
located in ~/.bigqueryrc
435-
index_col: str (optional)
436+
index_col : str (optional)
436437
Name of result column to use for index in results DataFrame
437-
col_order: list(str) (optional)
438+
col_order : list(str) (optional)
438439
List of BigQuery column names in the desired order for results
439440
DataFrame
440-
destination_table: string (optional)
441+
destination_table : string (optional)
441442
If provided, send the results to the given table.
442-
**kwargs: to be passed to bq.Client.Create(). Particularly: 'trace', 'sync',
443-
'api', 'api_version'
443+
**kwargs :
444+
To be passed to bq.Client.Create(). Particularly: 'trace',
445+
'sync', 'api', 'api_version'
444446
445447
Returns
446448
-------
447-
df: pandas DataFrame
449+
df: DataFrame
448450
DataFrame representing results of query
449451
450452
"""

0 commit comments

Comments
 (0)