Skip to content

Commit 7edfc3e

Browse files
authored
TST: Use pandas.api.types functions for dtypes checks (#262)
* TST: Use pandas.api.types functions for dtypes checks This should make checking for expected dtypes more robust. * Bump minimum pandas version for access to pandas.api.types module.
1 parent c840dbb commit 7edfc3e

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

ci/requirements-2.7.pip

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mock
2-
pandas==0.17.1
2+
pandas==0.19.0
33
google-auth==1.4.1
44
google-auth-oauthlib==0.0.1
55
google-cloud-bigquery==1.9.0

docs/source/changelog.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Dependency updates
1313

1414
- Update the minimum version of ``google-cloud-bigquery`` to 1.9.0.
1515
(:issue:`247`)
16+
- Update the minimum version of ``pandas`` to 0.19.0. (:issue:`262`)
1617

1718
Internal changes
1819
~~~~~~~~~~~~~~~~
@@ -23,7 +24,7 @@ Internal changes
2324
Enhancements
2425
~~~~~~~~~~~~
2526
- Allow ``table_schema`` in :func:`to_gbq` to contain only a subset of columns,
26-
with the rest being populated using the DataFrame dtypes (:issue:`218`)
27+
with the rest being populated using the DataFrame dtypes (:issue:`218`)
2728
(contributed by @johnpaton)
2829
- Read ``project_id`` in :func:`to_gbq` from provided ``credentials`` if
2930
available (contributed by @daureg)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def readme():
1818

1919
INSTALL_REQUIRES = [
2020
"setuptools",
21-
"pandas",
21+
"pandas>=0.19.0",
2222
"pydata-google-auth",
2323
"google-auth",
2424
"google-auth-oauthlib",

tests/system/test_gbq.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import google.oauth2.service_account
88
import numpy as np
99
import pandas
10+
import pandas.api.types
1011
import pandas.util.testing as tm
1112
from pandas import DataFrame, NaT, compat
1213
from pandas.compat import range, u
@@ -364,16 +365,18 @@ def test_should_properly_handle_arbitrary_datetime(self, project_id):
364365
)
365366

366367
@pytest.mark.parametrize(
367-
"expression, type_",
368+
"expression, is_expected_dtype",
368369
[
369-
("current_date()", "<M8[ns]"),
370-
("current_timestamp()", "datetime64[ns]"),
371-
("current_datetime()", "<M8[ns]"),
372-
("TRUE", bool),
373-
("FALSE", bool),
370+
("current_date()", pandas.api.types.is_datetime64_ns_dtype),
371+
("current_timestamp()", pandas.api.types.is_datetime64_ns_dtype),
372+
("current_datetime()", pandas.api.types.is_datetime64_ns_dtype),
373+
("TRUE", pandas.api.types.is_bool_dtype),
374+
("FALSE", pandas.api.types.is_bool_dtype),
374375
],
375376
)
376-
def test_return_correct_types(self, project_id, expression, type_):
377+
def test_return_correct_types(
378+
self, project_id, expression, is_expected_dtype
379+
):
377380
"""
378381
All type checks can be added to this function using additional
379382
parameters, rather than creating additional functions.
@@ -389,7 +392,7 @@ def test_return_correct_types(self, project_id, expression, type_):
389392
credentials=self.credentials,
390393
dialect="standard",
391394
)
392-
assert df["_"].dtype == type_
395+
assert is_expected_dtype(df["_"].dtype)
393396

394397
def test_should_properly_handle_null_timestamp(self, project_id):
395398
query = "SELECT TIMESTAMP(NULL) AS null_timestamp"

0 commit comments

Comments
 (0)