Skip to content

Commit 31c1ca2

Browse files
committed
chore: tweaks to eliminate broken docs links
1 parent b724547 commit 31c1ca2

File tree

3 files changed

+89
-25
lines changed

3 files changed

+89
-25
lines changed

packages/pandas-gbq/docs/intro.rst

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ Reading data from BigQuery
2727
Use the :func:`pandas_gbq.read_gbq` function to run a BigQuery query and
2828
download the results as a :class:`pandas.DataFrame` object.
2929

30-
.. literalinclude:: ../samples/snippets/read_gbq_simple.py
31-
:language: python
32-
:dedent: 4
33-
:start-after: [START bigquery_pandas_gbq_read_gbq_simple]
34-
:end-before: [END bigquery_pandas_gbq_read_gbq_simple]
30+
.. code-block:: python
31+
32+
import pandas_gbq
33+
34+
# TODO: Set project_id to your Google Cloud Platform project ID.
35+
# project_id = "my-project"
36+
37+
sql = """
38+
SELECT country_name, alpha_2_code
39+
FROM `bigquery-public-data.utility_us.country_code_iso`
40+
WHERE alpha_2_code LIKE 'A%'
41+
"""
42+
df = pandas_gbq.read_gbq(sql, project_id=project_id)
43+
print(df)
3544
3645
By default, queries use standard SQL syntax. Visit the :doc:`reading tables
3746
guide <reading>` to learn about the available options.
@@ -57,11 +66,29 @@ Writing data to BigQuery
5766
Use the :func:`pandas_gbq.to_gbq` function to write a
5867
:class:`pandas.DataFrame` object to a BigQuery table.
5968

60-
.. literalinclude:: ../samples/snippets/to_gbq_simple.py
61-
:language: python
62-
:dedent: 4
63-
:start-after: [START bigquery_pandas_gbq_to_gbq_simple]
64-
:end-before: [END bigquery_pandas_gbq_to_gbq_simple]
69+
.. code-block:: python
70+
71+
import pandas
72+
import pandas_gbq
73+
74+
# TODO: Set project_id to your Google Cloud Platform project ID.
75+
# project_id = "my-project"
76+
# TODO: Set table_id to the full destination table ID (including the
77+
# dataset ID).
78+
# table_id = 'my_dataset.my_table'
79+
80+
df = pandas.DataFrame(
81+
{
82+
"my_string": ["a", "b", "c"],
83+
"my_int64": [1, 2, 3],
84+
"my_float64": [4.0, 5.0, 6.0],
85+
"my_bool1": [True, False, True],
86+
"my_bool2": [False, True, False],
87+
"my_dates": pandas.date_range("now", periods=3),
88+
}
89+
)
90+
91+
pandas_gbq.to_gbq(df, table_id, project_id=project_id)
6592
6693
The destination table and destination dataset will automatically be created.
6794
By default, writes to BigQuery fail if the table already exists. Visit the

packages/pandas-gbq/docs/reading.rst

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ Reading Tables
66
Use the :func:`pandas_gbq.read_gbq` function to run a BigQuery query and
77
download the results as a :class:`pandas.DataFrame` object.
88

9-
.. literalinclude:: ../samples/snippets/read_gbq_simple.py
10-
:language: python
11-
:dedent: 4
12-
:start-after: [START bigquery_pandas_gbq_read_gbq_simple]
13-
:end-before: [END bigquery_pandas_gbq_read_gbq_simple]
9+
.. code-block:: python
10+
11+
import pandas_gbq
12+
13+
# TODO: Set project_id to your Google Cloud Platform project ID.
14+
# project_id = "my-project"
15+
16+
sql = """
17+
SELECT country_name, alpha_2_code
18+
FROM `bigquery-public-data.utility_us.country_code_iso`
19+
WHERE alpha_2_code LIKE 'A%'
20+
"""
21+
df = pandas_gbq.read_gbq(sql, project_id=project_id)
22+
print(df)
1423
1524
.. note::
1625

@@ -37,11 +46,21 @@ The ``dialect`` argument can be used to indicate whether to use
3746
BigQuery's ``'legacy'`` SQL or BigQuery's ``'standard'`` SQL. The
3847
default value is ``'standard'``.
3948

40-
.. literalinclude:: ../samples/snippets/read_gbq_legacy.py
41-
:language: python
42-
:dedent: 4
43-
:start-after: [START bigquery_pandas_gbq_read_gbq_legacy]
44-
:end-before: [END bigquery_pandas_gbq_read_gbq_legacy]
49+
.. code-block:: python
50+
51+
sql = """
52+
SELECT country_name, alpha_2_code
53+
FROM [bigquery-public-data:utility_us.country_code_iso]
54+
WHERE alpha_2_code LIKE 'Z%'
55+
"""
56+
df = pandas_gbq.read_gbq(
57+
sql,
58+
project_id=project_id,
59+
# Set the dialect to "legacy" to use legacy SQL syntax. As of
60+
# pandas-gbq version 0.10.0, the default dialect is "standard".
61+
dialect="legacy",
62+
)
63+
print(df)
4564
4665
* `Standard SQL reference
4766
<https://cloud.google.com/bigquery/docs/reference/standard-sql/>`__

packages/pandas-gbq/docs/writing.rst

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,29 @@ Writing Tables
66
Use the :func:`pandas_gbq.to_gbq` function to write a
77
:class:`pandas.DataFrame` object to a BigQuery table.
88

9-
.. literalinclude:: ../samples/snippets/to_gbq_simple.py
10-
:language: python
11-
:dedent: 4
12-
:start-after: [START bigquery_pandas_gbq_to_gbq_simple]
13-
:end-before: [END bigquery_pandas_gbq_to_gbq_simple]
9+
.. code-block:: python
10+
11+
import pandas
12+
import pandas_gbq
13+
14+
# TODO: Set project_id to your Google Cloud Platform project ID.
15+
# project_id = "my-project"
16+
# TODO: Set table_id to the full destination table ID (including the
17+
# dataset ID).
18+
# table_id = 'my_dataset.my_table'
19+
20+
df = pandas.DataFrame(
21+
{
22+
"my_string": ["a", "b", "c"],
23+
"my_int64": [1, 2, 3],
24+
"my_float64": [4.0, 5.0, 6.0],
25+
"my_bool1": [True, False, True],
26+
"my_bool2": [False, True, False],
27+
"my_dates": pandas.date_range("now", periods=3),
28+
}
29+
)
30+
31+
pandas_gbq.to_gbq(df, table_id, project_id=project_id)
1432
1533
The destination table and destination dataset will automatically be created
1634
if they do not already exist.

0 commit comments

Comments
 (0)