diff --git a/google/cloud/bigquery/_pandas_helpers.py b/google/cloud/bigquery/_pandas_helpers.py index cc0ee75ff..0d05f53a3 100644 --- a/google/cloud/bigquery/_pandas_helpers.py +++ b/google/cloud/bigquery/_pandas_helpers.py @@ -57,15 +57,9 @@ if pandas is not None: # pragma: NO COVER def _to_wkb(): - # Create a closure that: - # - Adds a not-null check. This allows the returned function to - # be used directly with apply, unlike `shapely.wkb.dumps`. - # - Avoid extra work done by `shapely.wkb.dumps` that we don't need. - # - Caches the WKBWriter (and write method lookup :) ) - # - Avoids adding WKBWriter, lgeos, and notnull to the module namespace. - from shapely.geos import WKBWriter, lgeos # type: ignore - - write = WKBWriter(lgeos).write + from shapely import wkb # type: ignore + + write = wkb.dumps notnull = pandas.notnull def _to_wkb(v): diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index 72eb1baf6..8e9e248c4 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -39,11 +39,11 @@ _COORDINATE_REFERENCE_SYSTEM = "EPSG:4326" try: - import shapely.geos # type: ignore + import shapely # type: ignore except ImportError: shapely = None else: - _read_wkt = shapely.geos.WKTReader(shapely.geos.lgeos).read + _read_wkt = shapely.wkt.loads import google.api_core.exceptions from google.api_core.page_iterator import HTTPIterator