Skip to content

Commit 04a9f11

Browse files
1 parent b8ff031 commit 04a9f11

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

‎google/cloud/bigquery/_pandas_helpers.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
try:
4949
import pandas_gbq.schema.pandas_to_bigquery # type: ignore
50-
50+
5151
pandas_gbq_import_exception = None
5252
except ImportError as exc:
5353
pandas_gbq = None
@@ -472,7 +472,8 @@ def dataframe_to_bq_schema(dataframe, bq_schema):
472472
)
473473
else:
474474
return pandas_gbq.schema.pandas_to_bigquery.dataframe_to_bigquery_fields(
475-
dataframe, override_bigquery_fields=bq_schema,
475+
dataframe,
476+
override_bigquery_fields=bq_schema,
476477
)
477478

478479
if bq_schema:

‎tests/unit/test__pandas_helpers.py‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,9 @@ def test_dataframe_to_parquet_compression_method(module_under_test):
12861286

12871287
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
12881288
@pytest.mark.skipif(pandas_gbq is None, reason="Requires `pandas-gbq`")
1289-
def test_dataframe_to_bq_schema_returns_schema_with_pandas_gbq(module_under_test, monkeypatch):
1289+
def test_dataframe_to_bq_schema_returns_schema_with_pandas_gbq(
1290+
module_under_test, monkeypatch
1291+
):
12901292
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
12911293
dataframe = pandas.DataFrame({"field00": ["foo", "bar"]})
12921294
got = module_under_test.dataframe_to_bq_schema(dataframe, [])
@@ -1297,7 +1299,7 @@ def test_dataframe_to_bq_schema_returns_schema_with_pandas_gbq(module_under_test
12971299
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
12981300
def test_dataframe_to_bq_schema_w_named_index(module_under_test, monkeypatch):
12991301
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
1300-
1302+
13011303
df_data = collections.OrderedDict(
13021304
[
13031305
("str_column", ["hello", "world"]),
@@ -1323,7 +1325,7 @@ def test_dataframe_to_bq_schema_w_named_index(module_under_test, monkeypatch):
13231325
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
13241326
def test_dataframe_to_bq_schema_w_multiindex(module_under_test, monkeypatch):
13251327
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
1326-
1328+
13271329
df_data = collections.OrderedDict(
13281330
[
13291331
("str_column", ["hello", "world"]),
@@ -1373,7 +1375,9 @@ def test_dataframe_to_bq_schema_w_bq_schema(module_under_test, monkeypatch):
13731375
]
13741376

13751377
with pytest.warns(FutureWarning, match="pandas-gbq"):
1376-
returned_schema = module_under_test.dataframe_to_bq_schema(dataframe, dict_schema)
1378+
returned_schema = module_under_test.dataframe_to_bq_schema(
1379+
dataframe, dict_schema
1380+
)
13771381

13781382
expected_schema = (
13791383
schema.SchemaField("str_column", "STRING", "NULLABLE"),
@@ -1384,7 +1388,9 @@ def test_dataframe_to_bq_schema_w_bq_schema(module_under_test, monkeypatch):
13841388

13851389

13861390
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
1387-
def test_dataframe_to_bq_schema_fallback_needed_wo_pyarrow(module_under_test, monkeypatch):
1391+
def test_dataframe_to_bq_schema_fallback_needed_wo_pyarrow(
1392+
module_under_test, monkeypatch
1393+
):
13881394
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
13891395

13901396
dataframe = pandas.DataFrame(
@@ -1414,9 +1420,11 @@ def test_dataframe_to_bq_schema_fallback_needed_wo_pyarrow(module_under_test, mo
14141420

14151421
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
14161422
@pytest.mark.skipif(isinstance(pyarrow, mock.Mock), reason="Requires `pyarrow`")
1417-
def test_dataframe_to_bq_schema_fallback_needed_w_pyarrow(module_under_test, monkeypatch):
1423+
def test_dataframe_to_bq_schema_fallback_needed_w_pyarrow(
1424+
module_under_test, monkeypatch
1425+
):
14181426
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
1419-
1427+
14201428
dataframe = pandas.DataFrame(
14211429
data=[
14221430
{"id": 10, "status": "FOO", "created_at": datetime.date(2019, 5, 10)},
@@ -1474,7 +1482,7 @@ def test_dataframe_to_bq_schema_pyarrow_fallback_fails(module_under_test, monkey
14741482
@pytest.mark.skipif(geopandas is None, reason="Requires `geopandas`")
14751483
def test_dataframe_to_bq_schema_geography(module_under_test, monkeypatch):
14761484
from shapely import wkt
1477-
1485+
14781486
monkeypatch.setattr(module_under_test, "pandas_gbq", None)
14791487

14801488
df = geopandas.GeoDataFrame(

0 commit comments

Comments
 (0)