Skip to content

Commit f777e67

Browse files
authored
DEPR: read_gbq, DataFrame.to_gbq (#55868)
* DEPR: read_gbq, DataFrame.to_gbq * reference pandas_gbq in deprecation note instead
1 parent 66b5235 commit f777e67

15 files changed

+40
-26
lines changed

ci/deps/actions-310.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ dependencies:
3939
- odfpy>=1.4.1
4040
- qtpy>=2.3.0
4141
- openpyxl>=3.1.0
42-
# Doesn't install well with pyarrow
43-
# https://github.com/pandas-dev/pandas/issues/55525
44-
# - pandas-gbq>=0.19.0
4542
- psycopg2>=2.9.6
4643
- pyarrow>=10.0.1
4744
- pymysql>=1.0.2

ci/deps/actions-311-downstream_compat.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ dependencies:
4040
- odfpy>=1.4.1
4141
- qtpy>=2.3.0
4242
- openpyxl>=3.1.0
43-
# Doesn't install well with pyarrow
44-
# https://github.com/pandas-dev/pandas/issues/55525
45-
# - pandas-gbq>=0.19.0
4643
- psycopg2>=2.9.6
4744
- pyarrow>=10.0.1
4845
- pymysql>=1.0.2

ci/deps/actions-311.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ dependencies:
3939
- odfpy>=1.4.1
4040
- qtpy>=2.3.0
4141
- openpyxl>=3.1.0
42-
# Doesn't install well with pyarrow
43-
# https://github.com/pandas-dev/pandas/issues/55525
44-
# - pandas-gbq>=0.19.0
4542
- psycopg2>=2.9.6
4643
- pyarrow>=10.0.1
4744
- pymysql>=1.0.2

ci/deps/actions-39-minimum_versions.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ dependencies:
4141
- odfpy=1.4.1
4242
- qtpy=2.3.0
4343
- openpyxl=3.1.0
44-
#- pandas-gbq=0.19.0
4544
- psycopg2=2.9.6
4645
- pyarrow=10.0.1
4746
- pymysql=1.0.2

ci/deps/actions-39.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ dependencies:
3939
- odfpy>=1.4.1
4040
- qtpy>=2.3.0
4141
- openpyxl>=3.1.0
42-
# Doesn't install well with pyarrow
43-
# https://github.com/pandas-dev/pandas/issues/55525
44-
# - pandas-gbq>=0.19.0
4542
- psycopg2>=2.9.6
4643
- pyarrow>=10.0.1
4744
- pymysql>=1.0.2

ci/deps/circle-310-arm64.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ dependencies:
3939
- odfpy>=1.4.1
4040
- qtpy>=2.3.0
4141
- openpyxl>=3.1.0
42-
# Doesn't install well with pyarrow
43-
# https://github.com/pandas-dev/pandas/issues/55525
44-
# - pandas-gbq>=0.19.0
4542
- psycopg2>=2.9.6
4643
- pyarrow>=10.0.1
4744
- pymysql>=1.0.2

doc/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@
457457
"dateutil": ("https://dateutil.readthedocs.io/en/latest/", None),
458458
"matplotlib": ("https://matplotlib.org/stable/", None),
459459
"numpy": ("https://numpy.org/doc/stable/", None),
460-
"pandas-gbq": ("https://pandas-gbq.readthedocs.io/en/latest/", None),
461460
"py": ("https://pylib.readthedocs.io/en/latest/", None),
462461
"python": ("https://docs.python.org/3/", None),
463462
"scipy": ("https://docs.scipy.org/doc/scipy/", None),

doc/source/whatsnew/v2.2.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ For example:
262262
Other Deprecations
263263
^^^^^^^^^^^^^^^^^^
264264
- Changed :meth:`Timedelta.resolution_string` to return ``h``, ``min``, ``s``, ``ms``, ``us``, and ``ns`` instead of ``H``, ``T``, ``S``, ``L``, ``U``, and ``N``, for compatibility with respective deprecations in frequency aliases (:issue:`52536`)
265+
- Deprecated :func:`read_gbq` and :meth:`DataFrame.to_gbq`. Use ``pandas_gbq.read_gbq`` and ``pandas_gbq.to_gbq`` instead https://pandas-gbq.readthedocs.io/en/latest/api.html (:issue:`55525`)
265266
- Deprecated :meth:`Index.format`, use ``index.astype(str)`` or ``index.map(formatter)`` instead (:issue:`55413`)
266267
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_clipboard`. (:issue:`54229`)
267268
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_csv` except ``path_or_buf``. (:issue:`54229`)

pandas/core/frame.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,10 @@ def to_gbq(
21342134
"""
21352135
Write a DataFrame to a Google BigQuery table.
21362136
2137+
.. deprecated:: 2.2.0
2138+
2139+
Please use ``pandas_gbq.to_gbq`` instead.
2140+
21372141
This function requires the `pandas-gbq package
21382142
<https://pandas-gbq.readthedocs.io>`__.
21392143

pandas/io/gbq.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
TYPE_CHECKING,
66
Any,
77
)
8+
import warnings
89

910
from pandas.compat._optional import import_optional_dependency
11+
from pandas.util._exceptions import find_stack_level
1012

1113
if TYPE_CHECKING:
1214
import google.auth
@@ -43,6 +45,10 @@ def read_gbq(
4345
"""
4446
Load data from Google BigQuery.
4547
48+
.. deprecated:: 2.2.0
49+
50+
Please use ``pandas_gbq.read_gbq`` instead.
51+
4652
This function requires the `pandas-gbq package
4753
<https://pandas-gbq.readthedocs.io>`__.
4854
@@ -178,6 +184,13 @@ def read_gbq(
178184
... dialect="standard"
179185
... ) # doctest: +SKIP
180186
"""
187+
warnings.warn(
188+
"read_gbq is deprecated and will be removed in a future version. "
189+
"Please use pandas_gbq.read_gbq instead: "
190+
"https://pandas-gbq.readthedocs.io/en/latest/api.html#pandas_gbq.read_gbq",
191+
FutureWarning,
192+
stacklevel=find_stack_level(),
193+
)
181194
pandas_gbq = _try_import()
182195

183196
kwargs: dict[str, str | bool | int | None] = {}
@@ -219,6 +232,13 @@ def to_gbq(
219232
progress_bar: bool = True,
220233
credentials: google.auth.credentials.Credentials | None = None,
221234
) -> None:
235+
warnings.warn(
236+
"to_gbq is deprecated and will be removed in a future version. "
237+
"Please use pandas_gbq.to_gbq instead: "
238+
"https://pandas-gbq.readthedocs.io/en/latest/api.html#pandas_gbq.to_gbq",
239+
FutureWarning,
240+
stacklevel=find_stack_level(),
241+
)
222242
pandas_gbq = _try_import()
223243
pandas_gbq.to_gbq(
224244
dataframe,

0 commit comments

Comments
 (0)