Skip to content

Commit 8c49892

Browse files
sumanau7Sumanau Sareen
authored and
Sumanau Sareen
committed
Send None parameter to pandas-gbq to set no progress bar
1 parent a6a1ab2 commit 8c49892

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

pandas/io/gbq.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def read_gbq(
3030
configuration: Optional[Dict[str, Any]] = None,
3131
credentials=None,
3232
use_bqstorage_api: Optional[bool] = None,
33-
private_key=None,
34-
verbose=None,
35-
progress_bar_type: Optional[str] = None,
33+
progress_bar_type: str = "NOT_SET",
3634
) -> "DataFrame":
3735
"""
3836
Load data from Google BigQuery.
@@ -125,13 +123,15 @@ def read_gbq(
125123
``fastavro`` packages.
126124
127125
.. versionadded:: 0.25.0
128-
progress_bar_type : Optional, str
126+
progress_bar_type : str
129127
If set, use the `tqdm <https://tqdm.github.io/>`__ library to
130128
display a progress bar while the data downloads. Install the
131129
``tqdm`` package to use this feature.
132130
133131
Possible values of ``progress_bar_type`` include:
134132
133+
``NOT_SET``
134+
Arg is not set by caller, don't including the argument in pandas-gbq call.
135135
``None``
136136
No progress bar.
137137
``'tqdm'``
@@ -159,6 +159,12 @@ def read_gbq(
159159
--------
160160
pandas_gbq.read_gbq : This function in the pandas-gbq library.
161161
DataFrame.to_gbq : Write a DataFrame to Google BigQuery.
162+
163+
Examples
164+
--------
165+
Read from google bigquery.
166+
167+
>>> pd.read_gbq(query='select 1')
162168
"""
163169
pandas_gbq = _try_import()
164170

@@ -167,8 +173,7 @@ def read_gbq(
167173
# START: new kwargs. Don't populate unless explicitly set.
168174
if use_bqstorage_api is not None:
169175
kwargs["use_bqstorage_api"] = use_bqstorage_api
170-
171-
if progress_bar_type is not None:
176+
if progress_bar_type != "NOT_SET":
172177
kwargs["progress_bar_type"] = progress_bar_type
173178
# END: new kwargs
174179

pandas/tests/io/test_gbq.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def mock_read_gbq(sql, **kwargs):
131131
assert "use_bqstorage_api" not in captured_kwargs
132132

133133

134-
@pytest.mark.parametrize("progress_bar", [None, "foo"])
134+
@pytest.mark.parametrize("progress_bar", [None, "foo", "NOT_SET"])
135135
def test_read_gbq_progress_bar_type_kwarg(monkeypatch, progress_bar):
136136
# GH 29857
137137
captured_kwargs = {}
@@ -142,11 +142,10 @@ def mock_read_gbq(sql, **kwargs):
142142

143143
monkeypatch.setattr("pandas_gbq.read_gbq", mock_read_gbq)
144144
pd.read_gbq("SELECT 1", progress_bar_type=progress_bar)
145-
146-
if progress_bar:
147-
assert "progress_bar_type" in captured_kwargs
148-
else:
145+
if progress_bar == "NOT_SET":
149146
assert "progress_bar_type" not in captured_kwargs
147+
else:
148+
assert "progress_bar_type" in captured_kwargs
150149

151150

152151
@pytest.mark.single

0 commit comments

Comments
 (0)