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

-3
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

-3
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

-3
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

-1
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

-3
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

-3
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

-1
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

+1
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

+4
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

+20
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,

pandas/tests/io/test_gbq.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pandas as pd
2+
import pandas._testing as tm
3+
4+
5+
def test_read_gbq_deprecated():
6+
with tm.assert_produces_warning(FutureWarning):
7+
with tm.external_error_raised(Exception):
8+
pd.read_gbq("fake")
9+
10+
11+
def test_to_gbq_deprecated():
12+
with tm.assert_produces_warning(FutureWarning):
13+
with tm.external_error_raised(Exception):
14+
pd.DataFrame(range(1)).to_gbq("fake")

pandas/tests/test_downstream.py

-5
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ def test_seaborn():
161161
seaborn.stripplot(x="day", y="total_bill", data=tips)
162162

163163

164-
def test_pandas_gbq():
165-
# Older versions import from non-public, non-existent pandas funcs
166-
pytest.importorskip("pandas_gbq", minversion="0.10.0")
167-
168-
169164
def test_pandas_datareader():
170165
pytest.importorskip("pandas_datareader")
171166

scripts/tests/data/deps_expected_random.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ dependencies:
3737
- numexpr>=2.7.3
3838
- openpyxl>=3.0.7
3939
- odfpy>=1.4.1
40-
- pandas-gbq>=0.15.0
4140
- psycopg2>=2.8.6
4241
- pyarrow<11, >=7.0.0
4342
- pymysql>=1.0.2

scripts/tests/data/deps_minimum.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ timezone = ['tzdata>=2022.1']
6161
computation = ['scipy>=1.7.1', 'xarray>=0.21.0']
6262
fss = ['fsspec>=2021.07.0']
6363
aws = ['s3fs>=2021.08.0']
64-
gcp = ['gcsfs>=2021.07.0', 'pandas-gbq>=0.15.0']
64+
gcp = ['gcsfs>=2021.07.0']
6565
excel = ['odfpy>=1.4.1', 'openpyxl>=3.0.7', 'python-calamine>=0.1.6', 'pyxlsb>=1.0.8', 'xlrd>=2.0.1', 'xlsxwriter>=1.4.3']
6666
parquet = ['pyarrow>=7.0.0']
6767
feather = ['pyarrow>=7.0.0']
@@ -94,7 +94,6 @@ all = ['beautifulsoup4>=5.9.3',
9494
'numexpr>=2.7.3',
9595
'odfpy>=1.4.1',
9696
'openpyxl>=3.0.7',
97-
'pandas-gbq>=0.15.0',
9897
'psycopg2>=2.8.6',
9998
'pyarrow>=7.0.0',
10099
'pymysql>=1.0.2',

scripts/tests/data/deps_unmodified_random.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ dependencies:
3737
- numexpr>=2.7.3
3838
- openpyxl>=3.0.7
3939
- odfpy>=1.4.1
40-
- pandas-gbq>=0.15.0
4140
- psycopg2
4241
- pyarrow<11, >=7.0.0
4342
- pymysql>=1.0.2

0 commit comments

Comments
 (0)