Skip to content

Commit 2e8d0be

Browse files
committed
BUG: only show verbose warning for new pandas versions.
1 parent 9ced97b commit 2e8d0be

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

docs/source/changelog.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.4.1 / 2018-04-05
5+
------------------
6+
7+
- Only show ``verbose`` deprecation warning if Pandas version does not
8+
populate it. (:issue:`157`)
9+
410
0.4.0 / 2018-04-03
511
------------------
612

pandas_gbq/gbq.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515

1616
BIGQUERY_INSTALLED_VERSION = None
17+
PANDAS_HAS_DEPRECATED_VERBOSITY = False
1718

1819

1920
def _check_google_client_version():
20-
global BIGQUERY_INSTALLED_VERSION
21+
global BIGQUERY_INSTALLED_VERSION, PANDAS_HAS_DEPRECATED_VERBOSITY
2122

2223
try:
2324
import pkg_resources
@@ -36,6 +37,14 @@ def _check_google_client_version():
3637
'current version {1}'.format(
3738
bigquery_minimum_version, BIGQUERY_INSTALLED_VERSION))
3839

40+
# Add check for Pandas version before showing deprecation warning.
41+
# https://github.com/pydata/pandas-gbq/issues/157
42+
pandas_installed_version = pkg_resources.get_distribution(
43+
'pandas').parsed_version
44+
pandas_version_wo_verbosity = pkg_resources.parse_version('0.23.0')
45+
PANDAS_HAS_DEPRECATED_VERBOSITY = (
46+
pandas_installed_version >= pandas_version_wo_verbosity)
47+
3948

4049
def _test_google_api_imports():
4150

@@ -791,14 +800,15 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
791800
DataFrame representing results of query
792801
793802
"""
794-
if verbose is not None:
803+
804+
_test_google_api_imports()
805+
806+
if verbose is not None and PANDAS_HAS_DEPRECATED_VERBOSITY:
795807
warnings.warn(
796808
"verbose is deprecated and will be removed in "
797809
"a future version. Set logging level in order to vary "
798810
"verbosity", FutureWarning, stacklevel=1)
799811

800-
_test_google_api_imports()
801-
802812
if not project_id:
803813
raise TypeError("Missing required parameter: project_id")
804814

@@ -920,7 +930,7 @@ def to_gbq(dataframe, destination_table, project_id, chunksize=None,
920930

921931
_test_google_api_imports()
922932

923-
if verbose is not None:
933+
if verbose is not None and PANDAS_HAS_DEPRECATED_VERBOSITY:
924934
warnings.warn(
925935
"verbose is deprecated and will be removed in "
926936
"a future version. Set logging level in order to vary "

0 commit comments

Comments
 (0)