Skip to content

DOC: Fixing EX01 - Added example #54126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 18, 2023
Merged
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.api.extensions.ExtensionArray.tolist \
pandas.DataFrame.pad \
pandas.DataFrame.plot \
pandas.DataFrame.to_gbq \
pandas.DataFrame.__dataframe__
RET=$(($RET + $?)) ; echo $MSG "DONE"

Expand Down
23 changes: 23 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,29 @@ def to_gbq(
--------
pandas_gbq.to_gbq : This function in the pandas-gbq library.
read_gbq : Read a DataFrame from Google BigQuery.

Examples
--------
Example taken from `Google BigQuery documentation
<https://cloud.google.com/bigquery/docs/samples/bigquery-pandas-gbq-to-gbq-simple>`_

>>> import pandas_gbq # doctest: +SKIP
# TODO: Set project_id to your Google Cloud Platform project ID.
>>> project_id = "my-project" # doctest: +SKIP
# TODO: Set table_id to the full destination table ID (including the
# dataset ID).
>>> table_id = 'my_dataset.my_table' # doctest: +SKIP
>>> df = pd.DataFrame({
... "my_string": ["a", "b", "c"],
... "my_int64": [1, 2, 3],
... "my_float64": [4.0, 5.0, 6.0],
... "my_bool1": [True, False, True],
... "my_bool2": [False, True, False],
... "my_dates": pd.date_range("now", periods=3),
... }
... )

>>> df.to_gbq(table_id, project_id=project_id) # doctest: +SKIP
"""
from pandas.io import gbq

Expand Down
5 changes: 4 additions & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ def pandas_validate(func_name: str):
)
examples_source_code = "".join(doc.examples_source_code)
for wrong_import in ("numpy", "pandas"):
if f"import {wrong_import}" in examples_source_code:
if (
f"import {wrong_import}" in examples_source_code
and "import pandas_gbq" not in examples_source_code
):
result["errors"].append(
pandas_error("EX04", imported_library=wrong_import)
)
Expand Down