Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Use pandas.api.types functions for dtypes checks #262

Merged
merged 3 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/requirements-2.7.pip
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mock
pandas==0.17.1
pandas==0.19.0
google-auth==1.4.1
google-auth-oauthlib==0.0.1
google-cloud-bigquery==1.9.0
Expand Down
3 changes: 2 additions & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Dependency updates

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

Internal changes
~~~~~~~~~~~~~~~~
Expand All @@ -23,7 +24,7 @@ Internal changes
Enhancements
~~~~~~~~~~~~
- Allow ``table_schema`` in :func:`to_gbq` to contain only a subset of columns,
with the rest being populated using the DataFrame dtypes (:issue:`218`)
with the rest being populated using the DataFrame dtypes (:issue:`218`)
(contributed by @johnpaton)
- Read ``project_id`` in :func:`to_gbq` from provided ``credentials`` if
available (contributed by @daureg)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def readme():

INSTALL_REQUIRES = [
"setuptools",
"pandas",
"pandas>=0.19.0",
"pydata-google-auth",
"google-auth",
"google-auth-oauthlib",
Expand Down
19 changes: 11 additions & 8 deletions tests/system/test_gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import google.oauth2.service_account
import numpy as np
import pandas
import pandas.api.types
import pandas.util.testing as tm
from pandas import DataFrame, NaT, compat
from pandas.compat import range, u
Expand Down Expand Up @@ -364,16 +365,18 @@ def test_should_properly_handle_arbitrary_datetime(self, project_id):
)

@pytest.mark.parametrize(
"expression, type_",
"expression, is_expected_dtype",
[
("current_date()", "<M8[ns]"),
("current_timestamp()", "datetime64[ns]"),
("current_datetime()", "<M8[ns]"),
("TRUE", bool),
("FALSE", bool),
("current_date()", pandas.api.types.is_datetime64_ns_dtype),
("current_timestamp()", pandas.api.types.is_datetime64_ns_dtype),
("current_datetime()", pandas.api.types.is_datetime64_ns_dtype),
("TRUE", pandas.api.types.is_bool_dtype),
("FALSE", pandas.api.types.is_bool_dtype),
],
)
def test_return_correct_types(self, project_id, expression, type_):
def test_return_correct_types(
self, project_id, expression, is_expected_dtype
):
"""
All type checks can be added to this function using additional
parameters, rather than creating additional functions.
Expand All @@ -389,7 +392,7 @@ def test_return_correct_types(self, project_id, expression, type_):
credentials=self.credentials,
dialect="standard",
)
assert df["_"].dtype == type_
assert is_expected_dtype(df["_"].dtype)

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