This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new 96d7cc8a12 [GH-2264] Geopandas: Support other of type GeoDataframe in 
row_wise_operations (#2265)
96d7cc8a12 is described below

commit 96d7cc8a1266d95c95cc6a6b839b320d4aaec72c
Author: Peter Nguyen <[email protected]>
AuthorDate: Mon Aug 11 22:53:10 2025 -0700

    [GH-2264] Geopandas: Support other of type GeoDataframe in 
row_wise_operations (#2265)
---
 python/sedona/spark/geopandas/geoseries.py |  4 +++-
 python/tests/geopandas/test_geoseries.py   | 33 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/python/sedona/spark/geopandas/geoseries.py 
b/python/sedona/spark/geopandas/geoseries.py
index ff3a5cb9dc..7580cf3793 100644
--- a/python/sedona/spark/geopandas/geoseries.py
+++ b/python/sedona/spark/geopandas/geoseries.py
@@ -2862,7 +2862,9 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
                 - Whether returned value was a single object extended into a 
series (useful for row-wise 'align' parameter)
         """
         # generator instead of a in-memory list
-        if not isinstance(value, pspd.Series):
+        if isinstance(value, GeoDataFrame):
+            return value.geometry, False
+        elif not isinstance(value, pspd.Series):
             lst = [value for _ in range(len(self))]
             if isinstance(value, BaseGeometry):
                 return GeoSeries(lst), True
diff --git a/python/tests/geopandas/test_geoseries.py 
b/python/tests/geopandas/test_geoseries.py
index 7365bdcdc9..9dcefc609b 100644
--- a/python/tests/geopandas/test_geoseries.py
+++ b/python/tests/geopandas/test_geoseries.py
@@ -1195,6 +1195,39 @@ e": "Feature", "properties": {}, "geometry": {"type": 
"Point", "coordinates": [3
         expected = GeometryCollection()
         self.check_geom_equals(result, expected)
 
+    def test_row_wise_dataframe(self):
+        s = GeoSeries(
+            [
+                Polygon([(0, 0), (1, 1), (0, 1)]),
+                Polygon([(0, 0), (1, 1), (0, 1)]),
+                Polygon([(0, 0), (1, 1), (0, 1)]),
+            ]
+        )
+        s2 = GeoSeries([Point(-5.5, 1), Point(1, 2), Point(3, 1)])
+
+        # self: GeoSeries, other: GeoDataFrame
+        expected = pd.Series([5.5, 1, 2])
+        result = s.distance(s2.to_geoframe())
+        self.check_pd_series_equal(result, expected)
+
+        # self: GeoDataFrame, other: GeoDataFrame
+        result = s.to_geoframe().distance(s2.to_geoframe())
+        assert_series_equal(result.to_pandas(), expected)
+
+        # Same but for overlay
+        expected = gpd.GeoSeries(
+            [
+                Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
+                Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
+                Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
+            ]
+        )
+        result = s.difference(s2.to_geoframe())
+        self.check_sgpd_equals_gpd(result, expected)
+
+        result = s.to_geoframe().difference(s2.to_geoframe())
+        self.check_sgpd_equals_gpd(result, expected)
+
     def test_crosses(self):
         s = GeoSeries(
             [

Reply via email to