From c473f7617725f9e353963f859c88210354ce331a Mon Sep 17 00:00:00 2001 From: Sumanau Sareen Date: Mon, 13 Apr 2020 11:13:40 +0530 Subject: [PATCH] Send None parameter to pandas-gbq to set no progress bar --- ci/deps/travis-36-locale.yaml | 2 +- doc/source/getting_started/install.rst | 2 +- doc/source/whatsnew/v1.1.0.rst | 3 +++ pandas/compat/_optional.py | 2 +- pandas/io/gbq.py | 5 ++--- pandas/tests/io/test_gbq.py | 6 +----- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ci/deps/travis-36-locale.yaml b/ci/deps/travis-36-locale.yaml index 3fc19f1bca084..2c8403acf6971 100644 --- a/ci/deps/travis-36-locale.yaml +++ b/ci/deps/travis-36-locale.yaml @@ -27,7 +27,7 @@ dependencies: - numexpr - numpy - openpyxl - - pandas-gbq=0.8.0 + - pandas-gbq=0.12.0 - psycopg2=2.6.2 - pymysql=0.7.11 - pytables diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index ba99aaa9f430c..da1161c8f68b4 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -274,7 +274,7 @@ lxml 3.8.0 HTML parser for read_html (see :ref matplotlib 2.2.2 Visualization numba 0.46.0 Alternative execution engine for rolling operations openpyxl 2.5.7 Reading / writing for xlsx files -pandas-gbq 0.8.0 Google Big Query access +pandas-gbq 0.12.0 Google Big Query access psycopg2 PostgreSQL engine for sqlalchemy pyarrow 0.12.0 Parquet, ORC (requires 0.13.0), and feather reading / writing pymysql 0.7.11 MySQL engine for sqlalchemy diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 86d3e50493bd1..17623b943bf87 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -289,6 +289,7 @@ Other enhancements - Make :class:`pandas.core.window.Rolling` and :class:`pandas.core.window.Expanding` iterable(:issue:`11704`) - Make ``option_context`` a :class:`contextlib.ContextDecorator`, which allows it to be used as a decorator over an entire function (:issue:`34253`). - :meth:`groupby.transform` now allows ``func`` to be ``pad``, ``backfill`` and ``cumcount`` (:issue:`31269`). +- :meth `~pandas.io.gbq.read_gbq` now allows to disable progress bar (:issue:`33360`). .. --------------------------------------------------------------------------- @@ -355,6 +356,8 @@ Optional libraries below the lowest tested version may still work, but are not c +-----------------+-----------------+---------+ | xlwt | 1.2.0 | | +-----------------+-----------------+---------+ +| pandas-gbq | 1.2.0 | X | ++-----------------+-----------------+---------+ See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more. diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index c5fd294699c45..0a5e0f5050040 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -15,7 +15,7 @@ "numexpr": "2.6.2", "odfpy": "1.3.0", "openpyxl": "2.5.7", - "pandas_gbq": "0.8.0", + "pandas_gbq": "0.12.0", "pyarrow": "0.13.0", "pytables": "3.4.3", "pytest": "5.0.1", diff --git a/pandas/io/gbq.py b/pandas/io/gbq.py index 405bf27cac02d..9b46f970afc66 100644 --- a/pandas/io/gbq.py +++ b/pandas/io/gbq.py @@ -162,14 +162,13 @@ def read_gbq( """ pandas_gbq = _try_import() - kwargs: Dict[str, Union[str, bool]] = {} + kwargs: Dict[str, Union[str, bool, None]] = {} # START: new kwargs. Don't populate unless explicitly set. if use_bqstorage_api is not None: kwargs["use_bqstorage_api"] = use_bqstorage_api - if progress_bar_type is not None: - kwargs["progress_bar_type"] = progress_bar_type + kwargs["progress_bar_type"] = progress_bar_type # END: new kwargs return pandas_gbq.read_gbq( diff --git a/pandas/tests/io/test_gbq.py b/pandas/tests/io/test_gbq.py index 7a5eba5264421..e9cefe3056130 100644 --- a/pandas/tests/io/test_gbq.py +++ b/pandas/tests/io/test_gbq.py @@ -142,11 +142,7 @@ def mock_read_gbq(sql, **kwargs): monkeypatch.setattr("pandas_gbq.read_gbq", mock_read_gbq) pd.read_gbq("SELECT 1", progress_bar_type=progress_bar) - - if progress_bar: - assert "progress_bar_type" in captured_kwargs - else: - assert "progress_bar_type" not in captured_kwargs + assert "progress_bar_type" in captured_kwargs @pytest.mark.single